SIMULATING A CALCULATOR step1 ) create a class which stores an integer value. Th
ID: 3633472 • Letter: S
Question
SIMULATING A CALCULATORstep1 ) create a class which stores an integer value. The constructor will initialize the value stored to a given number (parameter). Implement also the accessor (getValue) / mutator (setValue) methods to access / modify the content of the stored value. Test all your code (constructor and methods) in a file called TestCalculator.java.
The output of the program should look like (user input in bold).
Give an initial value for the stored value: 7
Test on constructor and getValue() method:
The value stored in the object is 7.
Test on setValue()method:
Give a new value for the stored value: -10
The new value stored in the object is -10.
Notes:
Step 2:) provide the services requested (calculating)
Provide the following methods to the class:
? public void add (int val): will add a given integer value to the one stored in the class.
? public void substract (int val): will subtract the given value to the one stored (note that a-b is different from b-a)
? public void multiply (int val): will multiply the given value to the one stored
? public void divide(int val): will divide the given value to the one stored.