急求解答一道Java作业题目
程序要求见下方图片另外希望能够加上说明:1.简要说明整体功能2.分别说明程序各部分的功能,成员变量的名称和含义,方法的实现过程3.main方法中的实际调用过程...
程序要求见下方图片另外希望能够加上说明:1.简要说明整体功能2.分别说明程序各部分的功能,成员变量的名称和含义,方法的实现过程3.main方法中的实际调用过程
展开
1个回答
展开全部
第一个类:
public class Student {
public String name;//姓名
public String sid;//学号
public String email;//邮件
public String school;//校名
public String grade;//年级
//根据姓名,学号输出基本信息
public void showMessage(){
String major;
int a=Integer.parseInt(sid.substring(9, 10));
switch (a) {
case 1:major="经济学";break;
case 2:major="金融学";break;
case 3:major="国际金融与贸易";break;
case 4:major="工商管理";break;
case 5:major="会计";break;
default:major="专业未定";break;
}
System.out.println("姓名:"+name+","+school+" "+major+" 专业 "+grade+" 级学生");
}
//显示email
public void showEmail(){
System.out.println("姓名:"+name+" "+"Email地址是:"+email);
}
//构造函数
public Student(String name, String sid, String email, String school, String grade) {
super();
this.name = name;
this.sid = sid;
this.email = email;
this.school = school;
this.grade = grade;
}
public Student() {
super();
}
}
第二个类:
public class Stu extends Student{
public int English;//英语成绩
public int math;//数学成绩
public int politics;//政治成绩
//构造函数
public Stu(String name, String sid, String email, String school, String grade, int english, int math,
int politics) {
super(name, sid, email, school, grade);
English = english;
this.math = math;
this.politics = politics;
}
//成绩管理
public void showScore(){
int sum=English+math+politics;//总分
int max,min;//最高分,最低分
max=English>math?English:math;
min=English>math?math:English;
max=max>politics?max:politics;
min=min<politics?min:politics;
System.out.println("学号:"+sid+" 姓名:"+name+" 总分:"+sum+" 最高分:"+max+" 最低分:"+min);
}
}
测试类:
public class MainTest {
public static void main(String[] args) {
Stu stu=new Stu("李四", "1200850202", "2012555@mail.bnu.edu.cn", "北京师范大学", "2015", 95, 85, 98);
stu.showMessage();//显示基本信息
stu.showEmail();//显示email
stu.showScore();//显示分数情况
}
}
public class Student {
public String name;//姓名
public String sid;//学号
public String email;//邮件
public String school;//校名
public String grade;//年级
//根据姓名,学号输出基本信息
public void showMessage(){
String major;
int a=Integer.parseInt(sid.substring(9, 10));
switch (a) {
case 1:major="经济学";break;
case 2:major="金融学";break;
case 3:major="国际金融与贸易";break;
case 4:major="工商管理";break;
case 5:major="会计";break;
default:major="专业未定";break;
}
System.out.println("姓名:"+name+","+school+" "+major+" 专业 "+grade+" 级学生");
}
//显示email
public void showEmail(){
System.out.println("姓名:"+name+" "+"Email地址是:"+email);
}
//构造函数
public Student(String name, String sid, String email, String school, String grade) {
super();
this.name = name;
this.sid = sid;
this.email = email;
this.school = school;
this.grade = grade;
}
public Student() {
super();
}
}
第二个类:
public class Stu extends Student{
public int English;//英语成绩
public int math;//数学成绩
public int politics;//政治成绩
//构造函数
public Stu(String name, String sid, String email, String school, String grade, int english, int math,
int politics) {
super(name, sid, email, school, grade);
English = english;
this.math = math;
this.politics = politics;
}
//成绩管理
public void showScore(){
int sum=English+math+politics;//总分
int max,min;//最高分,最低分
max=English>math?English:math;
min=English>math?math:English;
max=max>politics?max:politics;
min=min<politics?min:politics;
System.out.println("学号:"+sid+" 姓名:"+name+" 总分:"+sum+" 最高分:"+max+" 最低分:"+min);
}
}
测试类:
public class MainTest {
public static void main(String[] args) {
Stu stu=new Stu("李四", "1200850202", "2012555@mail.bnu.edu.cn", "北京师范大学", "2015", 95, 85, 98);
stu.showMessage();//显示基本信息
stu.showEmail();//显示email
stu.showScore();//显示分数情况
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询