public class Robot {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=20;
int steps=simulation(n);
simulation(n); //Calls the simulation method
}
public static int steps(int n){ //Start of method steps
int total = 0; //initalizing total
for (int i=0;i<=n;i++){ //incremental for loop
int steps = (int) (5 * Math.random()) - 1;//determines the random number of steps
total = total+steps; //adds the steps per try
}return total; //returns the total number of steps
}
public static int simulation(int n){//Star of metod simulation
int steps=0;
for(int i=1;i<=n;i++){ //incremental for loop
System.out.println("on simulation "+i+" the robot walked " //prints out the sim number total steps and in how many tries
+steps(n)+" in "+n+" tries");
steps= steps(n);
}return steps;
}
}