JAVA2程序设计实用教程之Java的面向对象特征上机实验实习报告|设计学生成绩表
实验目的
掌握Java的面向对象特征。
二、所用仪器、材料(设备名称、型号、规格等)
个人计算机一台
三、实验内容
1.设计学生成绩表
算法
package mypackage;
interface Student_info //学生情况接口
{
int year = 2006;
int age();void output();
}
interface Student_scoure //学生成绩接口
{
float total(); void output();
}
class Student implements Student_info, Student_scoure {
String name; String number; int birth_year;
float math,english,computer;
public Student(String na,String nu,int y,float a,float b,float c)
{
name = na; number=nu; birth_year = y;
math = a; english = b; computer = c;
}
public int age()
{
return year - birth_year;
}
public float total()
{
return math + english + computer;
}
public void output() //实现接口的方法
{
System.out.print(this .number+"|"+this.name +"| "+ this.age()+"岁 ");
System.out.println("|"+math +" "+ english +" "+ computer +" "+ total());
}
public static void main (String args[])
{
Student s[]=new Student[3];
s[0] = new Student("兔子","030405168",1985,90,80,70);
s[1]=new Student("祁宁","030405169",1984,88,85,76);
s[2]=new Student("范秀波","030405163",1983,90,86,82);
for(int i=0;i<3;i++)
s[i].output();
}
}范秀波
结果:若结果无法显示请联系站长QQ752018766