Question: 1. Write a program in C++ that simulates a n x n treasure map. a) Request a map size between 5 and 9. - Verify

1. Write a program in C++ that simulates a n x n treasure map.

a) Request a map size between 5 and 9. - Verify size with a validation loop. If size is incorrect, output an error and request new values.

b) Request a starting row/column for the treasure location on the map. - Validate row and column to insure that they fit on the map. If values are incorrect, output an error and request new values.

c) Use a nested loop to display the map (see output example). - X and Y coordinate labels should be displayed - Treasure location should be marked with an X. - Blank coordinates should be marked with a -.

d) Use a switch statement within a while loop to display menu options:

1) Update treasure coordinates (row/column)

2) Shift X (N S E W)

3) Exit Program

d) If 1 is selected: - Request row and column coordinate information. - Validate input with an error loop (similar to step b) - Display the updated map and menu options.

e) If 2 is selected: - Request a direction letter and integer offset(i.e. N 3 or W 2) - Use enumeration to recognize the N/S/E/W input in your menu. - Use direction and unit number to calculate a row or col offset for a new treasure location. - Validate the new location to insure that they fit on the map. If values are incorrect, output an error and request new values. - Display the updated map and menu options.

f) If 3 is selected: - Exit the menu while loop and output Exiting program.

Tips: This project requires the use of the following structures:

- nested loop (map)

- sentinel loop (program runs until exit option is input)

- switch based menu

- letter case conversion (direction input n should be same as input N)

- enumeration (translate NSEW into NORTH, SOUTH etc. for easy reading)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!