随笔 - 20  文章 - 57  trackbacks - 0
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(2)

随笔分类

随笔档案

文章分类

文章档案

51CTO

搜索

  •  

最新评论

阅读排行榜

评论排行榜

——————————
package package_1;
——————————
package package_1;
 
public class TextMyClass_1 {
 public static void main(String[] args){
    int[] A = new int[10];//存放成绩为A的学生在数组stud中的下表
    int[] B = new int[10];
    int[] C = new int[10];
    int[] D = new int[10];
    int[] E = new int[10];
   
    Student[] stud = new Student[9];   
    Student student1=new Student();
 student1.setName("张三");
 student1.setAge(22);
 student1.setClassroom("计算机3班");
 student1.setSocre(98);
 student1.setSex("爷们");
 stud[0]=student1;
 
 Student student2=new Student();
 student2.setName("李四");
 student2.setAge(22);
 student2.setClassroom("计算机3班");
 student2.setSocre(80);
 student2.setSex("爷们");
 stud[1]=student2;
 
 Student student3=new Student();
 student3.setName("王五");
 student3.setAge(22);
 student3.setClassroom("计算机3班");
 student3.setSocre(95);
 student3.setSex("爷们");;
 stud[2]=student3;
 
 Student student4=new Student();
 student4.setName("赵六");
 student4.setAge(22);
 student4.setClassroom("计算机3班");
 student4.setSocre(89);
 student4.setSex("女的");
 stud[3]=student4;
 
 Student student5=new Student();
 student5.setName("尽可");
 student5.setAge(23);
 student5.setClassroom("计算机3班");
 student5.setSocre(78);
 student5.setSex("爷们");
 stud[4]=student5;
 
 Student student6=new Student();
 student6.setName("女女");
 student6.setAge(22);
 student6.setClassroom("计算机3班");
 student6.setSocre(88);
 student6.setSex("女的");
 stud[5]=student6;
 
 Student student7=new Student();
 student7.setName("男男");
 student7.setAge(22);
 student7.setClassroom("计算机3班");
 student7.setSocre(60);
 student7.setSex("男的");
 stud[6]=student7;
   
 Student student8=new Student();
 student8.setName("鱼鱼");
 student8.setAge(22);
 student8.setClassroom("计算机3班");
 student8.setSocre(70);
 student8.setSex("男的");
 stud[7]=student8;
 
 Student student9=new Student();
 student9.setName("二胜");
 student9.setAge(25);
 student9.setClassroom("计算机3班");
 student9.setSocre(40);
 student9.setSex("男的");
 stud[8]=student9;
 int aa=0,bb=0,cc=0,dd=0,ee=0;
 for(int i=0;i<stud.length;i++){
  int pp;
  pp = stud[i].socre/10;
  switch(pp){
  case 9 : {
   A[aa]=i;
   aa++;
   break;
  }
  case 8 : {
   B[bb]=i;
   bb++;
   break;
  }
  case 7 : {
   C[cc]=i;
   cc++;
   break;
  }
  case 6 : {
   D[dd]=i;
   dd++;
   break;
  }
  case 5 : ;
  case 4 : ;
  case 3 : ;
  case 2 : ;
  case 1 : ;
  case 0 :{
   E[ee]=i;
   ee++;
   break;
  }
  }
 }
 System.out.println("成绩为A的同学一共有"+aa+"人");
 System.out.println("成绩为B的同学一共有"+bb+"人");
 System.out.println("成绩为C的同学一共有"+cc+"人");
 System.out.println("成绩是A的同学是:");
 for(int g=0;g<aa;g++){
 System.out.println("       " + stud[A[g]].classroom + "的" + stud[A[g]].name);
 }
 System.out.println("成绩是B的同学是:");
 for(int g=0;g<bb;g++){
 System.out.println("       " + stud[B[g]].classroom + "的" + stud[B[g]].name);
 }
 System.out.println("成绩是C的同学是:");
 for(int g=0;g<cc;g++){
 System.out.println("       " + stud[C[g]].classroom + "的" + stud[C[g]].name);
 }
 System.out.println("成绩是D的同学是:");
 for(int g=0;g<dd;g++){
 System.out.println("       " + stud[D[g]].classroom + "的" + stud[D[g]].name);
 }
 System.out.println("成绩不及格的同学是:");
 for(int g=0;g<ee;g++){
 System.out.println("       " + stud[E[g]].classroom + "的" + stud[E[g]].name);
 }
 }
}
 
 
 
 
————————————————————
package package_1;
————————————————————
 
package package_1;
public class MyClass_1 {
 //public static void main(String[] args){
  
 //}
}
class Student{
 public String name;
 public int age;
 public int socre;
 public String classroom;
 public String sex;
 
 public String getName(){
  return name;
 }
 public void setName(String name){
  this.name=name;
 }
 public int getAge(){
  return age;
 }
 public void setAge(int age){
  this.age=age;
 }
 public int getSocre(){
  return socre;
 }
 public void setSocre(int socre){
  this.socre=socre;
 }
 public String getSex(){
  return sex;
 }
 public void setSex(String sex){
  this.sex=sex;
 }
 public String getClassroom(){
  return classroom;
 }
 public void setClassroom(String classroom){
  this.classroom=classroom;
 }
}
 
posted on 2010-10-06 20:02 tovep 阅读(126) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
主页