posts - 17,  comments - 14,  trackbacks - 0
package gov.school.student;

public class Student {
    
    
    
private int stuno;
    
private String name;
    
private String sex;
    
private int age;
    
private int score;

    
public int getStuno() {
        
return stuno;
    }

    
public void setStuno(int stuno) {
        
this.stuno = stuno;
    }

    
public String getName() {
        
return name;
    }

    
public void setName(String name) {
        
this.name = name;
    }

    
public String getSex() {
        
return sex;
    }

    
public void setSex(String sex) {
        
this.sex = sex;
    }

    
public int getAge() {
        
return age;
    }

    
public void setAge(int age) {
        
this.age = age;
    }

    
public int getScore() {
        
return score;
    }

    
public void setScore(int score) {
        
this.score = score;
    }


}

package gov.school.student;

public class StudentServer {
    
    
public static Student[] getStudent()
    
{
        Student[] student 
= new Student[5];
        
        Student st0 
= new Student();
        st0.setAge(
20);
        st0.setName(
"老大");
        st0.setScore(
95);
        st0.setSex(
"");
        st0.setStuno(
1001);
        student[
0= st0;
        
        Student st1 
= new Student();
        st1.setAge(
21);
        st1.setName(
"老二");
        st1.setScore(
92);
        st1.setSex(
"");
        st1.setStuno(
1002);
        student[
1= st1;
        
        Student st2 
= new Student();
        st2.setAge(
22);
        st2.setName(
"老三");
        st2.setScore(
76);
        st2.setSex(
"");
        st2.setStuno(
1003);
        student[
2= st2;
        
        Student st3 
= new Student();
        st3.setAge(
28);
        st3.setName(
"老四");
        st3.setScore(
60);
        st3.setSex(
"");
        st3.setStuno(
1004);
        student[
3= st3;
        
        Student st4 
= new Student();
        st4.setAge(
20);
        st4.setName(
"老五");
        st4.setScore(
85);
        st4.setSex(
"");
        st4.setStuno(
1005);
        student[
4= st4;
        
        
return student;
        
    }


}

package gov.school.student;

public class StudentClient {
    
public static void main(String[] args)
    
{
        
// TODO Auto-generated method stub
        Student stud []=StudentServer.getStudent();
        String level
="a";
        
int q=0,w=0,e=0,r=0,t=0;
        
for (int i=0;i<stud.length;i++){
            
if (stud[i].getScore()>90){
                level
="A";
                q
++;
            }
else if(stud[ i].getScore()>80){
                level
="B";
                w
++;
            }
else if(stud[ i].getScore()>70){
                level
="C";
                e
++;
            }
else if(stud[ i].getScore()>60){
                level
="D";
                r
++;
            }
else {
                level
="E";
            }

        
        System.out.println(stud[i].getName()
+"  "+stud[i].getAge()+"岁,性别:   "+stud[i].getSex()+", 学号:"+stud[i].getStuno()+",  得分:   "+stud[i].getScore()+",   得分等级: "+level+"");
        }

        System.out.println(
"\n"+"等级为  A 的人数为:"+q);
        System.out.println(
"等级为  B 的人数为:"+w);
        System.out.println(
"等级为  C 的人数为:"+e);
        System.out.println(
"等级为  D 的人数为:"+r);
        System.out.println(
"等级为  E 的人数为:"+t);

    }


}


运行结果:

posted on 2010-10-10 18:21 Mineralwasser 阅读(170) 评论(3)  编辑  收藏

FeedBack:
# re: student
2010-10-10 18:33 | Tovep
LZ写的很好啊!   回复  更多评论
  
# re: student
2010-10-10 19:53 | 迷人笑笑
很不错啊!!前进的这么快!!呵呵--加油!!  回复  更多评论
  
# re: student
2010-10-10 22:41 | Mineralwasser
谢谢@迷人笑笑
  回复  更多评论
  

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


网站导航:
 
<2010年10月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(1)

文章档案(21)

搜索

  •  

最新评论

阅读排行榜

评论排行榜