7-1 java basic syntax - Integer Arithmetic (10 minutes)

Input two integers, and the output thereof, the difference between the product of the quotient and accurate.

Input formats:

Enter two integers

Output formats:

Sequentially outputting each row of four operation results

Sample input:

70
16 
 

Sample output:

Given here corresponding output. E.g:

86
54
1120
4.375










import java.util.Scanner;

public class Main{
public static void main(String args[]){
Scanner in= new Scanner(System.in);
int a=in.nextInt();
int b= in.nextInt();
System.out.println(a+b);
System.out.println(a-b);
System.out.println(a*b);
float c=(float)a/b;
System.out.println(c);
}
}
This place must pay attention to the division, the result may be a decimal
float c = (float)a/b;

Guess you like

Origin www.cnblogs.com/ywrxjry/p/12400349.html