Write a C++ program to simulate a simple calculator based on user input involving branch statements and loops! In the program, you can just use these statements: if, if-else, do-while, while, and switch.
Inside a loop, you will prompt for and read in the various user input and then perform the resulting calculations.
In particular, you will prompt for and read in a character representing the arithmetic operation he/she wishes to perform as follows: addition (+), subtraction (-), multiplication (*), division (/), and raising an integer to a power (^). If the user enters a character other than those listed here, you will display a meaningful error message indicating that the operation is invalid and not perform any calculation, but instead prompt the user for another computation.
You will then prompt for and read in the first operand, a positive integer. If the user does not enter a positive integer (i.e., > 0), you will display a meaningful error message and continue to re-prompt the user to enter the value.
Then, you will prompt for and read in the second operand, an integer. A couple of things to note with the second operand:
1. If the operation is division and the user enters a 0 for the second operand, you will display a meaningful error message indicating division by zero and not perform the operation.
2. If the operation is raising an integer to a power and the user enters an integer greater than 8 or less than -8, you will assign the value of the second operand to be a maximum power of 8 or a minimum power of -8 respectively, to prevent overflow or underflow.
You will then perform the requested arithmetic operation as input by the user, showing the details of the operation (i.e., the actual operation being performed) along with the results.
Finally, you will prompt for and read in whether or not the user would like to continue and perform another operation. If the user enters an affirmative answer, you will perform another iteration of the loop as described above; otherwise, you will terminate the program.