# Homework Solution: You have to write a program that will take as input from the command line two pairs of coordinates: the location of the robo…

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)).

import java.lang.*; class Robot {

You feel to transcribe a program that earn charm as input from the order bid span pairs of coordinates: the colony of the robot and the colony of the gold counterfeit. These must be well total. Your program has to do the following: 1. imitation the input: 2. quenchedput the consider of steps (i.e., squares) that the robot has to peregrination insipidly and perpendicularly to aim the gold counterfeit: 3. detail the orientation restraint the robot to peregrination twain insipidly (i.e., left or proper) and perpendicularly (i.e., up or down): and 4. consider and quenchedput which bid peregrinationled (insipid or perpendicular) is senior 5. Implement the program using arrays and loops to allow user decides when to surrender the program You can claim that the grid squares are considered affect a Cartesian (X-Y) graph, reasonh indisputable X going insipidly to the proper and indisputable Y going perpendicularly upwards. Input coordinates can be indirect, beside they must be well total. The quenchedput interspace must be indisputable and must be explicit in well total. illustration proceed. Below is a illustration proceed restraint span cases. The order bid is highlighted in valiant font. uName\$ java assignment1_yourName robot is at standing (8, 9) counterfeit is at standing (1, 7) robot peregrinations 7 steps to the left robot peregrinations 2 steps down robot peregrinations a senior interspace insipidly than perpendicularly Do you insufficiency to hold? java assignment1_yourName 8 9 8 1 robot is at standing (8, 9) counterfeit is at standing (8, 1) robot does referable peregrination insipidly robot peregrinations 8 steps down robot peregrinations a senior interspace perpendicularly than insipidly Do you insufficiency to hold? beginning jurisprudence. Your beginning jurisprudence (i.e., assignment1_yourName.java smooth) beside be handsome and explicitly illustrateed. You must feel a header illustrate and you should illustrate the object fill (i.e., each)).

import java.lang.*;
class Robot
{
public static lacking main(String args[])
{
int rx,ry,cx,cy;
rx=Integer.parseInt(args[0]); // Accept x treasure restraint Robot
ry=Integer.parseInt(args[1]); // Accept y treasure restraint Robot
cx=Integer.parseInt(args[2]); // Accept x treasure restraint Counterfeit
cy=Integer.parseInt(args[3]); // Accept y treasure restraint Counterfeit
System.out.println(“robot is at standing (“+rx+”,”+ry+”)”); // Display Standing
System.out.println(“counterfeit is at standing (“+cx+”,”+cy+”)”); // Display Standing
if(rx>cx) // Checking in Which bid Robot Should Move
System.out.println(“robot peregrinations “+(rx-cx)+” steps to the left”);
else if(rx<cx) // Checking in Which bid Robot Should Move
System.out.println(“robot peregrinations “+(cx-rx)+” steps to the proper”);
else
System.out.println(“robot does referable peregrination insipidly “);
if(ry>cy) // Checking in Which bid Robot Should Move
System.out.println(“robot peregrinations “+(ry-cy)+” steps down”);
else if(ry<cy) // Checking in Which bid Robot Should Move
System.out.println(“robot peregrinations “+(cy-ry)+” steps up”);
else
System.out.println(“robot does referable peregrination perpendicularly “);
if((Math.abs(rx-cx))>(Math.abs(ry-cy))) // Checking in Which bid it charms more
System.out.println(“robot peregrinations a senior interspace insipidly than perpendicularly”);
else if((Math.abs(rx-cx))<(Math.abs(ry-cy))) // Checking in Which bid it charms more
System.out.println(“robot peregrinations a senior interspace perpendicularly than insipidly”);
else
System.out.println(“The Robot is at its Correct Standing”);
}
}