[java]代码库
class Student{
private int id;
private String name;
private String sex;
private String leader;
private double match;
private double chinese;
private double english;
public int getId(){
return id;
}
public String getName(){
return name;
}
public String getSex(){
return sex;
}
public String getLeader(){
return leader;
}
public double getMatch(){
return match;
}
public double getChinese(){
return chinese;
}
public double getEnglish(){
return english;
}
public void setId(int stuId){
id=stuId;
}
public void setName(String stuName){
name= stuName;
}
public void setSex(String stuSex){
sex= stuSex;
}
public void setLeader(String stuLeader){
leader= stuLeader;
}
public void setMatch(double stuMatch){
if(stuMatch<0)
match=0;
else
match=stuMatch;
}
public void setChinese(double stuChinese){
if(stuChinese<0)
chinese=0;
else
chinese=stuChinese;
}
public void setEnglish(double stuEnglish){
if(stuEnglish<0)
english=0;
else
english= stuEnglish;
}
}
public class test3_1 {
public static void main(String args[]){
Student s1=new Student();
Student s2=new Student();
s1.setId(0001);
s1.setName("刘2");
s1.setSex("男");
s1.setLeader("是");
s1.setMatch(96);
s1.setChinese(94);
s1.setEnglish(86);
s2.setId(0002);
s2.setName("张三");
s2.setSex("女");
s2.setLeader("否");
s2.setMatch(98);
s2.setChinese(92);
s2.setEnglish(65);
System.out.println(s1.getName()+"的总成绩为"+(s1.getChinese()+s1.getEnglish()+s1.getMatch())+",平均分为:"+((s1.getChinese()+s1.getEnglish()+s1.getMatch())/3));
System.out.println(s2.getName()+"的总成绩为"+(s2.getChinese()+s2.getEnglish()+s2.getMatch())+",平均分为:"+((s2.getChinese()+s2.getEnglish()+s2.getMatch())/3));
}
}
初级程序员
by: 菜鸟慢飞 发表于:2018-09-13 08:19:41 顶(0) | 踩(0) 回复
可以,很基础
回复评论