import java.util.Scanner; /** * * @Title 总成绩和平均分计算 * @Description 依次输入一个学生的3科成绩,在屏幕上输出该学生的总成绩以及平均成绩。 * 输入描述: * 一行,3科成绩,成绩之间用一个空格隔开。 * 输出描述: * 一行,总成绩和平均成绩(小数点后保留两位),用一个空格隔开。 * @author weijunfu<ijunfu @ qq.com> * @date 2022/03/18 00:23 * @version 1.0.0 * */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double s1 = in.nextDouble(); double s2 = in.nextDouble(); double s3 = in.nextDouble(); double sum = s1 + s2 + s3; System.out.printf("%.2f %.2f", sum, sum/3); in.close(); } }
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner input = new Scanner(System.in); double a=input.nextDouble(); double b=input.nextDouble(); double c=input.nextDouble(); double sum=a+b+c; double avg=sum/3; System.out.println(String.format("%.2f", sum)+" "+String.format("%.2f", avg)); } }
import java.util.*; public class Main { public static void main(String [] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextDouble()) { double a=sc.nextDouble(); double b=sc.nextDouble(); double c=sc.nextDouble(); double sum=a+b+c; double avg=(a+b+c)/3; System.out.printf("%.2f",sum); System.out.print(" "); System.out.printf("%.2f",avg); } } }
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); double score1=scanner.nextDouble(); double score2=scanner.nextDouble(); double score3=scanner.nextDouble(); double sum=score1+score2+score3; double avg=sum/3; System.out.println(String.format("%.2f",sum)+" "+String.format("%.2f",avg)); } }