7-2 sdut-入门-三个整数和、积与平均值 (5 分)
给出三个整数,请你设计一个程序,求出这三个数的和、乘积和平均数。
输入格式:
输入只有三个正整数a、b、c。数据之间用一个空格隔开。
输出格式:
输出一行,包括三个的和、乘积、平均数。 数据之间用一个空格隔开,其中平均数保留小数后面两位。
输入样例:
2 3 3
输出样例:
8 18 2.67
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//int a,b,c;
Scanner input = new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
int sum = a + b + c;
int product = a * b * c;
double average = sum / 3.00;
System.out.println(sum+" "+product+" "+String.format("%.2f",average));
//format:规范输出
}
}