1 package com.yhqtv.duotai; 2 3 import java.util.Scanner; 4 import java.util.Vector; 5 6 public class Test { 7 8 public static void main(String[] args) { 9 Scanner sc=new Scanner(System.in); 10 Vector v=new Vector(); 11 12 int max=0; 13 for (;;){ 14 System.out.println("请输入学生成绩,以负数结束"); 15 int scores = sc.nextInt(); 16 if(scores<0){ 17 break; 18 } 19 if(scores>100){ 20 continue; 21 } 22 23 v.addElement(scores); 24 if(max<scores){ 25 max=scores; 26 } 27 } 28 char level; 29 for (int i = 0; i < v.size(); i++) { 30 Integer in=(Integer)v.elementAt(i); 31 int i1 = max - in; 32 if(i1<10){ 33 level='A'; 34 }else if (i1<20){ 35 level='B'; 36 }else if (i1<30){ 37 level='C'; 38 }else { 39 level='D'; 40 } 41 42 System.out.println("student"+i+" scores-"+in+" level-"+level); 43 } 44 } 45 }