1 package JavaApplication; 2 import java.util.Scanner; 3 import java.util.Arrays; 4 public class Scores 5 { 6 public static void main(String[] args) 7 { 8 Scanner scanner=new Scanner(System.in); 9 double scores[]=new double[4]; 10 System.out.println("请输入学生成绩:"); 11 for(int i=0;i<scores.length;i++) 12 { 13 scores[i]=scanner.nextDouble(); 14 } 15 System.out.println("学生的成绩信息为(正序输出):"); 16 for(double x:scores) 17 { 18 System.out.print(x+" "); 19 } 20 System.out.println(); 21 System.out.println("学生的成绩信息为(逆序输出):"); 22 for(int i=scores.length-1;i>=0;i--) 23 { 24 System.out.print(scores[i]+" "); 25 } 26 System.out.println(); 27 Arrays.sort(scores); 28 System.out.println("最低分为:"+scores[0]); 29 System.out.println("最高分为:"+scores[scores.length-1]); 30 scanner.close(); 31 } 32 }