编写一个JAVA程序,要求用户输入两个整数num1和num2,然后输出它们的和、差、积、商、余数、平均数和最大值。
时间: 2023-10-23 20:13:03 浏览: 47
```
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入两个整数:");
int num1 = scanner.nextInt();
int num2 = scanner.nextInt();
int sum = num1 + num2;
int diff = num1 - num2;
int product = num1 * num2;
int quotient = num1 / num2;
int remainder = num1 % num2;
double average = (double)(num1 + num2) / 2;
int max = num1 > num2 ? num1 : num2;
System.out.println("和:" + sum);
System.out.println("差:" + diff);
System.out.println("积:" + product);
System.out.println("商:" + quotient);
System.out.println("余数:" + remainder);
System.out.println("平均数:" + average);
System.out.println("最大值:" + max);
}
}
```
阅读全文