java郑州轻工业OJ1009

版权声明:小白一枚,敬请指导! https://blog.csdn.net/super_lu_sir/article/details/81541113

1009: 求平均分

时间限制: 1 Sec  内存限制: 30 MB
提交: 16851  解决: 11609
[提交][状态][讨论版][命题人:admin]

题目描述

已知某位学生的数学、英语和计算机课程的成绩,求该生三门课程的平均分。

输入

输入三个整数,数据之间由空格隔开。

输出

输出占一行,包含一个实数,为三门课的平均分,保留两位小数。

样例输入

87 73 93

样例输出

84.33
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
//已知某位学生的数学、英语和计算机课程的成绩,求该生三门课程的平均分。

	private static Scanner cin;

	public static void main(String[] args) {
		// 从键盘接收数据
		Scanner scanner = new Scanner(System.in);
		cin = new Scanner(System.in);
		int m, n, x;
		double y;
		m = cin.nextInt();
		n = cin.nextInt();
		x = cin.nextInt();

		DecimalFormat df = new DecimalFormat("0.00");// 格式化小数
		String num = df.format((float) (m + n + x) / 3);// 返回的是String类型

		System.out.println(num);

	}

}

猜你喜欢

转载自blog.csdn.net/super_lu_sir/article/details/81541113