Specifications:
1.Create a new project named COSC240 _< your username>_Project5.
2.Design an integer calculator class that at least has the following methods:
a.addition: take two parameters and return the sum
b.subtraction: take two parameters and return the remainder
c.multiplication: take two parameters and return the product
d.division: take two parameters and return the quotient
e.modulo: take two parameters and return the remainder
f.square: take one parameter and return the square of it
g.square root: take one parameter and return the square root of it
3.Design a test class (with the static void main method) to test your integer calculator class:
a.The test program will give the user a list of calculation options, and user will make a choice based on the list by typing in the number of one of the list item given;
b.The test program will first process the user request, then prompt for user input(s) based on how many parameters are needed for that calculation;
c.After user typed in the input(s) the test program will print out the result, and then print the list of calculation options again;
d.This loop will continue until the user choose the stop option;
e.Your test program is required to use at least one switch statement and a dowhile loop;
f.You only need to do integer calculation which means if the result is a float then it can be truncated.
4.Hints:
a.For calculate the square root you need to call java.lang.Math.sqrt();
b.For keyboard input you can use java.util.Scanner class. Please read the Java 6 API to find out have to use the Scanner class to read values from the keyboard (System.in);
c.A sample run of your program might look like this (red parts are user inputs):
Integer Calculator written by
Please choose from the following options:
1 : addition
2 : subtraction
3 : multiplication
4 : division
5 : modulo
6 : square
7 : square root
0 : STOP
1
Thank you for choosing addition.
Please enter the first number to be added:
13
Please enter the second number to be added:
17
Calculation: 13 + 17 = 30
Please choose from the following options:
1 : addition
2 : subtraction
3 : multiplication
4 : division
5 : modulo
6 : square
7 : square root
0 : STOP
7
Thank you for choosing square root.
Please enter the number to be square rooted:
67
Calculation: sqrt(67) = 8
.
.
.
< more tests are omitted here >
.
.
.
Please choose from the following options:
1 : addition
2 : subtraction
3 : multiplication
4 : division
5 : modulo
6 : square
7 : square root
0 : STOP
0
Thank you for using my calculator.
Program exits . . .