How do I to?:
Write a C# program that simulates a simple calculator. Initially, the user chooses an operation:
Please choose an operation (+,-,*,/):+
Repeat that user input until he/she has entered one of the four operator symbols (+, , *, /). Then, ask the user needs to enter two double operands:
Please enter first operand: 12.34
Please enter second operand: 45.67
Repeat that user input until the user has entered two numbers.
Now use a “switch” statement to test for the four different operands:
Switch
(operator) {
case “+”:
result = addNumbers (first, second);
break;
...
}
Each operand triggers invoking a separate method (addNumber,
subtractNumber, multiplyNumber, divideNumber) and assigning the result to a doublevariable “result”. Finally, print out:
The result of <first> <operator> <second> is: <result>.