Question: Write a class that calculates add, subtraction, and multiplication. The class should include the following methods: Constructor : initialize all values to 0 getAsk() :

Write a class that calculates add, subtraction, and multiplication. The class should include the following methods:

Constructor : initialize all values to 0

getAsk() : Ask users to input two integer numbers. This mehod calls

Distribute() method. Distribute() : Ask users to choose which calculation he/she wants. This method calls a method that can add, subtract, or multiply based on the user's option.

CalAdd() : add two numbers

CalSub() : subtract two numbers

CalProduct() : multiply two numbers

toString() : toString method that display result of operation.

The program should be designed to test the class developed. Your program might look like the following:

public class CalculateNumTesting {

public static void main(String[] args) {

CalculateNum calculation = new CalculateNum();

calculation.getAsk();

System.out.println(calculation);

}

}

The actual output of the program looks like following:

Write a class that calculates add, subtraction, and multiplication. The class should

65 C:\Windows\system32\cmd.exe Enter first number: 4 Enter second number: 3 Which one do you want? A: add S: subtract M: multiplication >> M The result of the calculation is 12.0 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!