public static void main(String[] args) { // 使用数组:动态录入学生个数 以及学生成绩 求总成绩 以及最值 Scanner input=new Scanner(System.in); System.out.println("请输入学生个数"); int num=input.nextInt(); double[] score=new double[num]; double sum=0.0; double maxscore; double minscore; for(int i=0;i<num;i++){ System.out.println("请输入学生成绩"); score[i]=input.nextDouble(); sum+=score[i]; } maxscore=score[0]; minscore=score[0]; for(int i=0;i<num;i++){ maxscore=(maxscore>score[i])?maxscore:score[i]; minscore=(minscore<score[i])?minscore:score[i]; } System.out.println(sum); System.out.println("最高分"+maxscore); System.out.println("最低分"+minscore); }
标签:double,minscore,个数,学生,录入,最值 From: https://www.cnblogs.com/Liku-java/p/16788270.html