Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The pilots of your airplanes have given you a lot of feedback and you have noticed many of them want a menu where they can

image text in transcribed
image text in transcribed
image text in transcribed
The pilots of your airplanes have given you a lot of feedback and you have noticed many of them want a menu where they can select the calculations they need to effectively fly the aircraft. There are five options the pilots need: 1. Slope 2. X-Axis Distance 3. Y-Axis Distance 4. Manhattan Distance 5. Euclidean Distance Since you want the pilots to be happy with your aircrafts you decide to implement these new features using the following algorithm: 1. Prompt the pilot for an option using the following menu: Select an option: (S/s) 1ope (X/x)-Axis Distance (Y/y)Axis Distance (M/m) anhattan Distance (E/e) uclidean Distance (Q/q) uit Selection: 2. A character selection can then be read in from the user. The user can enter anything though, so the input must be verified. To do this a switch statement must be implemented which allows for any of the character options from ths menu in (1) (i.e. 'S', 's', ' X ', ' x,Y,,M ', 'm', ' E ', ' e ', ' Q ', and ' q '). If the user doesn't enter one of these options then an error message, "Error: Invalid option" should be displayed and the program should terminate. Note: You must use a switch statement to perform this step or you will risk losing all points for this assignment. 3. If ' S ' or ' s ' is entered then the pilot wants the slope to an object. To calculate the slope you will need 2(x,y) points. Prompt the user for 2(x,y) points (similar to the previous assignment), read them in as doubles, and validate that each input was a valid number. If an invalid entry happens, output "Error: Invalid input" and terminate the program. If you get 2 valid (x,y) points then calculate the slope and output it. The formula for slope between two points is: slope=(y2y1)/(x2x1) 4. If ' X ' or ' x ' is entered then the pilot wants the x-axis distance from an object. Prompt the user for 2(x,y) points (similar to the previous assignment), read them in as doubles, and validate that each input was a valid number. If an invalid entry happens, output "Error: Invalid input" and terminate the program. If you get 2 valid (x,y) points then calculate the x-axis distance and output it. Remember, the formula for x-axis distance is: xdistance=x2x1 5. If ' Y ' or ' y ' is entered then the pilot wants the y-axis distance from an object. Prompt the user for 2(x,y) points (similar to the previous assignment), read them in as doubles, and validate that each input was a valid number. If an invalid entry happens, output "Error: Invalid input" and terminate the program. If you get 2 valid (x,y) points then calculate the y-axis distance and output it. Remember, the formula for y-axis distance is: ydistance=y2y1 6. If ' M ' or ' m ' is entered then the pilot wants the manhattan distance from an object. Prompt the user for 2(x,y) pontits (similar to the previous assignment), read them in as doubles, and validate that each input was a valid number. If an invalid entry happens, output "Error: Invalid input" and terminate the program. If you get 2 valid (x,y) points then calculate the manhattan distance and output it. Remember, the formula for manhattan distance is: manhattandistance=x2x1+y2y1 7. If ' E ' or ' e ' is entered then the pilot wants the euclidean distance from an object. Prompt the user for 2(x,y) points (similar to the previous assignment), read them in as doubles, and validate that each input was a valid number. If an invalid entry happens, output "Error: Invalid input" and terminate the program. If you get 2 valid (x,y) points then calculate the euclidean distance and output it. Remember, the formula for euclidean distance is: euclideandistance=(x2x1)2+(y2y1)2 8. If ' Q ' or ' q ' is entered then the pilot must have accidentally run the program. Do nothing and quit the program. Validating Inputs When a selection is made on what calculation the pilot wants the pilot could enter an invalid selection. Since a switch statement is forced in this assignment to choose a selection the easiest way to check for this is using the default case of the switch statement. When numerical inputs are read in from the user for the (x,y) coordinates the user can enter anything (including something that is not a number). To fix this you will need to check for input failure when reading in the points by checking the fail bit for cin

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

=+b For what range of unit sales will Rainbow Rugs prefer option 2?

Answered: 1 week ago