首页 > 其他 > 详细

IO-03. 求整数均值

时间:2014-09-05 17:56:01      阅读:218      评论:0      收藏:0      [点我收藏+]

本题要求编写程序,计算4个整数的和与平均值。题目保证输入与输出均在整型范围内。

输入格式:

输入在一行中给出4个整数,其间以空格分隔。

输出格式:

在一行中按照格式“Sum = 和; Average = 平均值”顺序输出和与平均值,其中平均值精确到小数点后1位。

输入样例:
1 2 3 4
输出样例:
Sum = 10; Average = 2.5
import java.util.Scanner;
public class Main {
     public static void main(String[] args)
         {
             Scanner input = new Scanner(System.in);
             int a = input.nextInt();
             int b = input.nextInt();
             int c = input.nextInt();
             int d = input.nextInt();
             double Average = (double)(a+b+c+d)/4;
             System.out.print("Sum = "+(a+b+c+d)+"; "+"Average = "+Average);
         }
}

 

IO-03. 求整数均值

原文:http://www.cnblogs.com/lsgcoder101/p/3958281.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!