输入三门功课的成绩,计算总分与平均分(JAVA)
发布网友
发布时间:2022-04-19 14:19
我来回答
共1个回答
热心网友
时间:2022-07-10 22:47
public static void main(String[] args) {
int score_c;
int score_java;
int score_sql;
int sum;
System.out.print("输入C的成绩:");
Scanner in = new Scanner(System.in);
score_c = in.nextInt();
System.out.print("输入Java的成绩:");
score_java = in.nextInt();
System.out.print("输入SQL的成绩:");
score_sql = in.nextInt();
System.out.println("==============================");
System.out.println("STB\tJava\tSQL");
System.out.println(score_c + "\t" + score_java + "\t" + score_sql);
System.out.println("==============================");
sum = score_c + score_java + score_sql;
System.out.println("三门课程的总分:" + sum);
System.out.println("三门课程的平均分:" + sum / 3);
}
运行结果: