/* Multilevel Inheritance */
import java.io.*;
class Student
{
String name;
int age;
void gets()
{
try
{
DataInputStream br=new DataInputStream(System.in);
System.out.println("Enter the name");
name=br.readLine();
System.out.println("Enter the age");
age=Integer.parseInt(br.readLine());
}catch(Exception e) { }
}
}
class Details extends Student
{
float mark1,mark2,mark3,mark4,mark5;
float average;
String msg="";
void get()
{
super.gets();
try
{
DataInputStream br=new DataInputStream(System.in);
System.out.println("Enter the Paper1 Mark");
mark1=Float.parseFloat(br.readLine());
System.out.println("Enter the Paper2 Mark");
mark2=Float.parseFloat(br.readLine());
System.out.println("Enter the Paper3 Mark");
mark3=Float.parseFloat(br.readLine());
System.out.println("Enter the Paper4 Mark");
mark4=Float.parseFloat(br.readLine());
System.out.println("Enter the Paper5 Mark");
mark5=Float.parseFloat(br.readLine());
}catch(Exception e) { }
}
void Print()
{
System.out.println("Name\t"+"Age\t"+"Mark1\t"+"Mark2\t"+"Mark3\t"+"Mark4\t"+"Mark5\t"+"Total\t"+"Average\t"+"Result");
System.out.println("********************************************************************************");
System.out.print(name+"\t");
System.out.print(age+"\t");
float total,average,result;
System.out.print(mark1+"\t");
System.out.print(mark2+"\t");
System.out.print(mark3+"\t");
System.out.print(mark4+"\t");
System.out.print(mark5+"\t");
result=mark1+mark2+mark3+mark4+mark5;
average=result/5;
System.out.print(result+"\t");
System.out.print(average+"\t");
if(average >=59.00)
System.out.print("II class\t\t");
else if(average >=69.00)
System.out.print("I class\t\t");
else if(average >=79.00)
System.out.print("Distinction\t\t");
else
System.out.print("Fail");
}
}
class Result
{
public static void main(String args[])
{
Details d[]=new Details[5];
for(int i=0;i<=5;i++)
{
new Details();
d[i]=new Details();
d[i].get();
d[i].Print();
}
}
}
No comments:
Post a Comment