Write a complete C++ program consisting of the main function and a void function. The program uses the void function to display the following menu: 1. Square root of sum 2. Logarithm to base e of sum of squares Please enter your choice The program then prompts for and reads two values x and y each of type double. It then uses a switch statement to do the following, based on the selected choice: • Choice 1: The program displays the value of sqrt(x + y) if x + y is greater than or equal to zero; otherwise it displays an appropriate error message. • Choice 2: The program displays the value of log(x* x + y * y) if x2 + y2 is greater than zero; otherwise it displays an appropriate error message. If a choice other than 1 or 2 is entered an error message must be displayed in the switch statement.
Write a complete C++
1. Square root of sum
2. Logarithm to base e of sum of squares
Please enter your choice
The program then prompts for and reads two values x and y each of type double. It then uses a switch statement to do the following, based on the selected choice:
• Choice 1: The program displays the value of sqrt(x + y) if x + y is greater than or equal to zero; otherwise it displays an appropriate error message.
• Choice 2: The program displays the value of log(x* x + y * y) if x2 + y2 is greater than zero; otherwise it displays an appropriate error message.
If a choice other than 1 or 2 is entered an error message must be displayed in the switch statement.
Step by step
Solved in 2 steps with 4 images