LanQiaoTestCodes/成绩统计.java

36 lines
1.0 KiB
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package LanQiaoOJ;
import java.util.Scanner;
/*
* 题目描述
小蓝给学生们组织了一场考试,卷面总分为 100 分,每个学生的得分都是一个 0 到 100 的整数。
如果得分至少是 60 分,则称为及格。如果得分至少为 85 分,则称为优秀。
请计算及格率和优秀率,用百分数表示,百分号前的部分四舍五入保留整 数。
输入描述
输入的第一行包含一个整数 n (1≤n≤10^4),表示考试人数。
接下来 n行每行包含一个 0 至 100 的整数,表示一个学生的得分。
输出描述
输出两行,每行一个百分数,分别表示及格率和优秀率。百分号前的部分 四舍五入保留整数。*/
public class 成绩统计 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int [] arr=new int[n];
int count=0,mark=0;
for(int i=0;i<n;i++) {
arr[i]=sc.nextInt();
if(arr[i]>=60){
if(arr[i]>=85){
mark++;
}
count++;
}
}
System.out.println((Math.round(count*100)/n)+"%");
System.out.println(Math.round((mark*100)/n)+"%");
}
}