Web viewoop=Double. parseDouble (ref2); String ref3=JOptionPane. showInputDialog ("Enter the marks...

3
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()); } }

Transcript of Web viewoop=Double. parseDouble (ref2); String ref3=JOptionPane. showInputDialog ("Enter the marks...

Page 1: Web viewoop=Double. parseDouble (ref2); String ref3=JOptionPane. showInputDialog ("Enter the marks of DLD"); double. la=Double. parseDouble (ref3); marks . ob =new

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());

}

}

Page 2: Web viewoop=Double. parseDouble (ref2); String ref3=JOptionPane. showInputDialog ("Enter the marks of DLD"); double. la=Double. parseDouble (ref3); marks . ob =new

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;}}

Page 3: Web viewoop=Double. parseDouble (ref2); String ref3=JOptionPane. showInputDialog ("Enter the marks of DLD"); double. la=Double. parseDouble (ref3); marks . ob =new

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;}

}