思路:
/*
*Math.round()方法四舍五入
*/
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//在此输入您的代码...
int num, count;
double pass = 0, out = 0;
num = scan.nextInt();
for(int i = 0; i < num; i ++){
count = scan.nextInt();
if(count >= 60){
if(count >= 85){
out ++;
}
pass ++;
}
}
System.out.println(Math.round(pass/num*100) + "%");
System.out.println(Math.round(out/num*100) + "%");
scan.close();
}
}
//Math.round方法
对数值进行+0.5向下取整的操作
例如:Math.round(1.5) == 1.5 + 0.5 == 2.