Question: C++ Question, Only the bonus program is needed And here is the sample output Instructions Write a program named lunarlander.cpp that Declares a 2D integer

C++ Question, Only the bonus program is needed

C++ Question, Only the bonus program is needed And here is the

And here is the sample output

sample output Instructions Write a program named lunarlander.cpp that Declares a 2Dinteger array of size 10*10 that represents the terrain Uses random number

Instructions Write a program named lunarlander.cpp that Declares a 2D integer array of size 10*10 that represents the terrain Uses random number generation to populate safe and unsafe locations of the terrain . o Each location in the grid has 50% probability to be safe and 50% to be unsafe Safe locations are represented by the number 1 Unsafe locations are represented by the number 0 o o . Displays a well-formatted table that visualizes the terrain . Prompts the user to enter the (x, y) coordinates of the desired landing location . Implements and calls a function that attempts to land the lunar lander o bool land (int location); * If the location is safe, change its value to 3 (using int location) to indicate the lunar lander has landed successfully Parameters: int location: a pointer to the element in the 2D array that was selected by the user - Return value . true: if the location is safe . false: if the location is unsafe . If the location is unsafe, displays a message to the user and prompts for another (x, y) coordinates to You may NOT use any global variables in this program Optional Bonus (+4 points) attempt a landing, until a successful one is entered Write a program named lunarrover.cpp that extends the functionality of lunarlander.cpp by: Prompting the user to enter one of four directions in which to move: left, right, up, down . o Validate the user input for one of the four possibilities o For example, do not accept an attempted move to the left from (0, 5) o bool move (int told location, int new location) Making sure that the proposed move keeps the rover inside the grid . Implementing a function that simulates the movement of the lunar rover: . If the new location is safe, change its value to 3 and the old location to 1 to indicate a successful move, then return true * If the new location is unsafe, then return false In a loop, prompt the user to move the rover until it attempts an unsafe move . You may NOT use any global variables in this program

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!