69 668
Assignments Done
99,4%
Successfully Done
In February 2019

Answer to Question #59273 in Java | JSP | JSF for Peter

Question #59273
Question: Create the following class in Java as specified in the UML diagram below:

SimpleCalc

+ SimpleCalc()
+ subtract (int, int):int
+ multiply (int, int): int
+ divide (int, int): double

â€˘ Create an application program (useCalc.java) with a main method. Within this method instantiate/create an object of SimpleCalc and test all four of its methods. Run the useCalc.java class.

public class useCalc {
public static void main(String[] args) {
int a = 10, b = 3;
System.out.println("a = " + a);
System.out.println("b = " + b);
SimpleCalc calc = new SimpleCalc();
System.out.println("a + b = " + calc.add(a,b));
System.out.println("a - b = " + calc.subtract(a,b));
System.out.println("a * b = " + calc.multiply(a,b));
System.out.println("a / b = " + calc.divide(a,b));
}
}

public class SimpleCalc {

public SimpleCalc(){}

public int add(int a, int b){
return a + b;
}

public int subtract (int a, int b){
return a - b;
}
public int multiply (int a, int b){
return a * b;
}
public double divide (int a, int b){
return (double)a / b;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!