Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++) A robot is initially located at position (0, 0) in a grid [5, 5] [5, 5]. The robot can move randomly in any of

(C++) A robot is initially located at position (0, 0) in a grid [5, 5] [5, 5]. The robot can move randomly in any of the directions: up, down, left, right. For each move, print the direction of the move and the current position of the robot. If the robot makes a circle, which means it moves back to the original place, print Back to the origin! to the console and stop the program. If it reaches the boundary of the grid, print Hit the boundary! to the console and stop the program.

A successful run of your code may look like:

Down (0,-1)

Down (0,-2)

Up (0,-1)

Left (-1,-1)

Left (-2,-1)

Up (-2,0)

Left (-3,0)

Left (-4,0)

Left (-5,0)

Hit the boundary!

or

Left (-1,0)

Down (-1,-1)

Right (0,-1)

Up (0,0)

Back to the origin!

Instructions: This program is to give you practice using the control flow, the random number generator, and output formatting. You may not use stdafx.h. Include header comments. Include to format your output. MAKE SURE THE COLUMNS ARE EVEN IN SPACES

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago