Write a program in java to simulate the operation of a simple robot . the robot
ID: 652749 • Letter: W
Question
Write a program in java to simulate the operation of a simple robot . the robot moves in four directions :forward , right , left. the job of the robot is to move items and place it in the right slots in each station. there are 8 stations plus the pick up station . the pick up station is the initial start where the robot picks the items . 8 items can be placed on each station .The nearest station must be filled before placing items on the next station. the items are marked with identification or serial numbers. the items with odd serial number go to the right and the items with even number go the left .the last slot, number 7 is reserved for heavy items which are less than 80 kg. the serial number is a five digit number , the MSBdigit 5 indicates that the product must be placed in the fifth station which is keeping the product at 20 degree F.
Explanation / Answer
import java.io.*;
class dt_robo
{
public static void main(String[] args)
{
int a[][] = new int[8][8];
int a1[][] = new int[8][8];
int a2[][] = new int[8][8];
int a3[][] = new int[8][8];
DataInputStream o = new DataInputStream(System.in);
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
n=Integer.parseInt(o.readLine());
if((n%2)==0)
{
a[i][j]=n;
}
else
{
a1[i][j]=n;
}
if((n>80)
{
a2[i][j]=n;
}
else
{
a3[i][j]=n;
}
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.