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.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 11E
icon
Related questions
Question

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.

Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr