AcWing 661. 平均数3 - Java
原题链接
中等
作者:
KYCygni
,
2021-03-12 07:17:46
,
所有人可见
,
阅读 405
Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
double avg = cin.nextDouble() * 0.2;
avg += cin.nextDouble() * 0.3;
avg += cin.nextDouble() * 0.4;
avg += cin.nextDouble() * 0.1;
System.out.println("Media: " + String.format("%.1f", avg));
if (avg > 7.0)
System.out.println("Aluno aprovado.");
else if (avg < 5.0)
System.out.println("Aluno reprovado.");
else
{
System.out.println("Aluno em exame.");
double y = cin.nextDouble();
System.out.println("Nota do exame: " + y);
avg = (avg + y)/2;
if (avg >= 5.0)
System.out.println("Aluno aprovado.");
else
System.out.println("Aluno reprovado.");
System.out.println ("Media final: " + String.format("%.1f", avg));
}
}
}