0% found this document useful (0 votes)
11 views2 pages

Sample Program Exercise

JAVA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Sample Program Exercise

JAVA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import [Link].

*;
import [Link];
//main class
class a {
public static void main(String [] args) {
Scanner scanner = new Scanner([Link]);
double k,j;
Grade g=new Grade();
Greater greater=new Greater();
[Link] ("Enter number 1");
k= [Link]();
[Link] ("Enter number 2");
j= [Link]();
greater.setNum1(k);
greater.setNum2(j);
[Link]("The greater number of "+greater.getNum1()+"
eater.getNum2()+" "+"is" + [Link]());
Total n = new Total ();
n.setNum1(k);
n.setNum2(j);
[Link] ( [Link]() );
}
}

class Grade {
double a,b;
void setNum1(double k){
a= k;
}
void setNum2(double n){
b= n;
}
double getNum1(){
return a;
}
double getNum2(){
return b;
}
}
class Greater extends Grade {

double larger()

"+ gr

{
if (a > b)
return a;
else
return b;
}
}
class Total extends Grade
{
double tot;
double Findtotal()
{
return tot = (a+ b)/ 2;
}
}

You might also like