Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a program that simulates a n x n treasure map. a) Request a map size between 5 and 9. Verify size with a

1. Write a program 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 are within the borders of 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 left or right.

3) Shift X up or down.

4) 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 (-/+) horizontal offset. Negative right, positive left. - Validate proposed location with an error loop. If location cannot exist on the current map, output an error and repeat request. - Display the updated map and menu options.

f) If 3 is selected: - Request a (-/+) vertical offset. Negative up, positive down. - Validate proposed location with an error loop. If location cannot exist on the current map, report an error and repeat request. - Display the updated map and menu options.

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

Hints: (1) create an integer variable dimension.

(2) create a global while loop with 4 as the sentinel value

(3) create a switch statement for the menu within the while loop

(4) create the map with a nested loop using the dimension variable

(5) use branching mechanisms within the loop to set and update X.

(6) use do/while loop structures to validate input values

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

Step: 3

blur-text-image

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

What is passive and active stealth? Give examples.

Answered: 1 week ago