Question: How do I program this in C++? Write a program named lunarlander.cpp that: Declares a 2D integer array of size 10*10 that represents the terrain

How do I program this in C++?

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 o Safe locations are represented by the number 1 o Unsafe locations are represented by the number 0

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

bool land(int location);

If the location is safe, whoever calls land should change its value to 3 to indicate the lunar lander has landed successfully

Parameters: int location: a variable 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 attempt a landing, until a successful one is entered. You may NOT use any global variables in this program.

This is the sample output of the program.

A game uses a 10*10 grid to represent the terrain of the surface of the moon on which a lunar lander may land. Unfortunately, not all parts of the surface are safe to land. Unsafe locations are indicated by 0s and safe locations are left blank.

How do I program this in C++? Write a program named lunarlander.cpp

| 0 1 2 3 45 6789 110 0 0 0 00 5 0 6100 0 7100 0 81000 0 0

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!