从键盘输入三个整数,分别存入x,y,z三个整型变量中,计算并输出三个数的和以及平均值。java
时间: 2023-10-19 19:06:31 浏览: 32
Java输入三个整数并把他们由小到大输出(x,y,z)
5星 · 资源好评率100%
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x = scanner.nextInt();
int y = scanner.nextInt();
int z = scanner.nextInt();
int sum = x + y + z;
double avg = sum / 3.0;
System.out.println("三个数的和为:" + sum);
System.out.println("三个数的平均值为:" + avg);
}
}
阅读全文