The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 327 Weeks Ago, 5 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
import java.util.Scanner;
Â
public class TestMathOP {
public static void main(String args[]){
Â
MathOP mytest1 = new MathOP();
MathOP mytest2 = new MathOP();
double add;
double sub;
Â
/*
scanner class for taking integer input
*/
Â
Scanner input = new Scanner(System.in);
int f = 0;
Â
while(f == 0)//while for program
{
add = mytest1.mathadd(5.5,7.5);
System.out.println("The sum of two number is " +add);
Â
//get values of subtraction
sub = mytest2.mathsub(5.5,7.5);
System.out.println("The subtraction of two number is " +sub);
Â
System.out.println("Do you want to exist (Y=1/N=0)?");
Â
f = input.nextInt();//here we are taking value from keybord 1 or 0 for exit or reapeat programm
Â
if (f==1)
{
Â
System.out.println("Thanks for using our system");
break;
}
else
{
System.out.println("run the program again");
}
}
}
}
Â
import java.util.*;
public class MathOP{
//create a method mathadd
double mathadd(double a,double b){
return a+b;
}
// create a method mathsub
double mathsub(double x,double z){
return x-z;
}
}
I need help, is not working right