• 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.
1
Expert's answer
2016-04-19T10:22:05-0400
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; } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment