import
javax.swing.JOptionPane;
class
student
{
int rno;
void readdata1()
{
rno=Integer.parseInt(JOptionPane.showInputDialog("Enter
roll number"));
}
void printdata1()
{
System.out.println("Roll
Number="+rno);
}
}
class
exam extends student
{
int m1,m2,m3;
void readdata2()
{
readdata1();
m1=Integer.parseInt(JOptionPane.showInputDialog("Enter
sub1 marks"));
m2=Integer.parseInt(JOptionPane.showInputDialog("Enter
sub2 marks"));
m3=Integer.parseInt(JOptionPane.showInputDialog("Enter
sub3 marks"));
}
void printdata2()
{
printdata1();
System.out.println("Sub 1
marks="+m1);
System.out.println("Sub 2
marks="+m2);
System.out.println("Sub 3
marks="+m3);
}
}
class
results extends exam
{
int avg;
void printdata3()
{
printdata2();
avg=(m1+m2+m3)/3;
if(avg<35)
System.out.println("FAIL");
else if(avg>=35 &&
avg<50)
System.out.println("THIRD
CLASS");
else if(avg>=50 &&
avg<60)
System.out.println("SECOND
CLASS");
else if(avg>=60 &&
avg<75)
System.out.println("FIRST
CLASS");
else if(avg>=75)
System.out.println("DISTINCTION");
}
}
class
mi
{
public static void main(String[]
args)
{
results obj=new
results();
obj.readdata2();
obj.printdata3();
}
}
No comments:
Post a Comment