Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have to write a program that will take as input from the command line two pairs of coordinates: the location of the robot and

image text in transcribed
You have to write a program that will take as input from the command line two pairs of coordinates: the location of the robot and the location of the gold coin. These must be whole numbers. Your program has to do the following: 1. echo the input: 2. output the number of steps (i.e., squares) that the robot has to travel horizontally and vertically to reach the gold coin: 3. specify the orientation for the robot to travel both horizontally (i.e., left or right) and vertically (i.e., up or down): and 4. calculate and output which direction travelled (horizontal or vertical) is greater 5. Implement the program using arrays and loops to let user decides when to quit the program You can assume that the grid squares are numbered like a Cartesian (X-Y) graph, with positive X going horizontally to the right and positive Y going vertically upwards. Input coordinates can be negative, but they must be whole numbers. The output distance must be positive and must be expressed in whole numbers. sample run. Below is a sample run for two cases. The command line is highlighted in bold font. uName$ java assignment1_yourName robot is at position (8, 9) coin is at position (1, 7) robot travels 7 steps to the left robot travels 2 steps down robot travels a greater distance horizontally than vertically Do you want to continue? java assignment1_yourName 8 9 8 1 robot is at position (8, 9) coin is at position (8, 1) robot does not travel horizontally robot travels 8 steps down robot travels a greater distance vertically than horizontally Do you want to continue? source code. Your source code (i.e., assignment1_yourName.java file) but be neat and clearly commented. You must have a header comment and you should comment the end block (i.e., each))

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago