Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

un C++ Write a program that accepts the following commands from the user: move; turnLefto; quit Note that both move(); and turn Left(); have to

image text in transcribedun

C++

Write a program that accepts the following commands from the user: move; turnLefto; quit Note that both move(); and turn Left(); have to be written precisely as defined, including the parentheses and semicolon. quit, likewise, has to be written precisely as defined: the word quit, with no parentheses or semicolon. Your program should continue prompting the user for more input until they enter the quit command. Your prompt should look as follows -- you must follow this format exactly: Please enter a comand: If the user enters anything but the commands above, print Invalid command And then ask the user to enter another command. Create variables to keep track of the row and column that Karel is standing at, and the direction Karel is facing. You may use whatever type makes sense to store these variables. Karel should start at location (0,0) -- the top left of the board, which is different from where our Karel IDE starts -- and should initially be facing east. Each time the user enters a command, print Karel's location and the direction that Karel is currently facing. You must EXACTLY follow the format below: Karel is at location Crow, col) facing direction. The size of Karel's world should be given as a pair of constants named ROWS and COLUMNS. Set ROWS equal to 6 and COLUMNS equal to 8. If Karel should try to move outside of the bounds of this world, print a message that says that Karel has crashed and then exit the program. Follow this format EXACTLY: Karel tried to move to location Crow, colum?). Karel has crashed! When the user enters the quit command, print out Karel's final location and direction faced, then thank the user for not crashing Karel. Follow this format EXACTLY: Karel finished at location Crow, col) facing direction. Thank you for not crashing Karel

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_2

Step: 3

blur-text-image_3

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions