So I finally got the main part of my code working... have to simulate a robot taking random steps but now i cant figure out how to get the average of steps he took throughout the whole code
any ideas? i need to add the amount of steps taken per simulation, and im really not sure how.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; } }