web viewoop=double. parsedouble (ref2); string ref3=joptionpane. showinputdialog ("enter the...

Post on 06-Feb-2018

215 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

package inheritance;import javax.swing.*;public class main {

public static void main(String[] args ) {// TODO Auto-generated method stub

String ref=JOptionPane.showInputDialog("Enter the marks of DLD");double dld=Double.parseDouble(ref);String ref2=JOptionPane.showInputDialog("Enter the marks of

DLD");double oop=Double.parseDouble(ref2);String ref3=JOptionPane.showInputDialog("Enter the marks of

DLD");double la=Double.parseDouble(ref3);marks ob=new marks(dld,oop,la);JOptionPane.showMessageDialog(null,"The percentage is

"+ob.getpercentage()+"\nThe Grade is "+ob.getgrade());

}

}

package inheritance;

public class grade {private char grade;private double percentage1;

void setpercentage1(double percentage){

percentage1=percentage;}

char getgrade(){

if(percentage1>=90)grade='A';

elseif(percentage1>=80)

grade='B';else

if(percentage1>=70)grade='C';

elsegrade='F';

return grade;}}

package inheritance;

public class marks extends grade{private double DLD;private double OOP;private double LA;private double totalmarks;private double percentage;marks(double dld,double oop,double la){DLD=dld;OOP=oop;LA=la;totalmarks=DLD+OOP+LA;percentage=(totalmarks/300)*100;setpercentage1(percentage);

}double getpercentage(){

return percentage;}

}

top related