Percentage Of Student - Multiple Inheritance

2 comments - Post a comment

--BY Joel Mathias
Program that makes use of Multilevel Inheritance in java
/* program To Implement Multilevel Inheritance */
class Fe
{
double fp;
int fr;

Fe(double p1,int r1)
{
fp = p1;
fr = r1;
}
}

class Se extends Fe
{
double sp;
int sr;

Se(double p1,int r1,double p2,int r2)
{
super(p1,r1);
sp = p2;
sr = r2;
}
}

class Te extends Se
{
double tp;
int tr;

Te(double p1,int r1,double p2,int r2,double p3,int r3)
{
super(p1,r1,p2,r2);
tp = p3;
tr = r3;
}

double average()
{
return (fp+sp+tp)/3;
}
}

class Student
{
public static void main(String args[])
{
Te student = new Te(78.5,41,71.73,44,79.8,48);
System.out.println("Year\tRoll no.\tPercentage");
System.out.println("FE\t"+student.fr+"\t\t"+student.fp);
System.out.println("SE\t"+student.sr+"\t\t"+student.sp);
System.out.println("TE\t"+student.tr+"\t\t"+student.tp);
System.out.println("\nAverage Performance is " + student.average());
}
}

/* Output *

Year Roll no. Percentage
FE 41 78.5
SE 44 71.73
TE 48 79.8

Average Performance is 76.67666666666668 */

 
This Post has 2 Comments Add your own!
AM's - February 13, 2011 at 2:34 PM

this program is not multiple inheritance

Anonymous - March 9, 2012 at 12:36 PM

it is of multilevel inheritance

Post a Comment