package day_09;
/用集合存储学生成绩,打印输出学生成绩及等级
import java.util.Scanner;
import java.util.Vector;
public class TestScore {
public static void main(String[] args){
Scanner s=new Scanner(System.in);
Vector v=new Vector();
int maxscore=0;
System.out.println("请输入学生成绩(以负数结束)");
for(;;){
int score=s.nextInt();
if(score>=0){
v.addElement(score);
}else{
break;
}
}
for(int i=0;i<v.size();i++){
Integer t=(Integer)v.elementAt(i);
if(t>=maxscore){
maxscore=t;
}
}
for(int i=0;i<v.size();i++){
Integer t=(Integer)v.elementAt(i);
if(maxscore-t<=10){
System.out.println("成绩是 "+t+"等级是A");
} else if(maxscore-t<=20){
System.out.println("成绩是 "+t+"等级是B");
} else if(maxscore-t<=30){
System.out.println("成绩是 "+t+"等级是C");
}else{
System.out.println("成绩是 "+t+"等级是D");
}
}
}
}
/用集合存储学生成绩,打印输出学生成绩及等级
import java.util.Scanner;
import java.util.Vector;
public class TestScore {
public static void main(String[] args){
Scanner s=new Scanner(System.in);
Vector v=new Vector();
int maxscore=0;
System.out.println("请输入学生成绩(以负数结束)");
for(;;){
int score=s.nextInt();
if(score>=0){
v.addElement(score);
}else{
break;
}
}
for(int i=0;i<v.size();i++){
Integer t=(Integer)v.elementAt(i);
if(t>=maxscore){
maxscore=t;
}
}
for(int i=0;i<v.size();i++){
Integer t=(Integer)v.elementAt(i);
if(maxscore-t<=10){
System.out.println("成绩是 "+t+"等级是A");
} else if(maxscore-t<=20){
System.out.println("成绩是 "+t+"等级是B");
} else if(maxscore-t<=30){
System.out.println("成绩是 "+t+"等级是C");
}else{
System.out.println("成绩是 "+t+"等级是D");
}
}
}
}