I\'m not sure where to start on this assignment. The language is Java. I underst
ID: 3673964 • Letter: I
Question
I'm not sure where to start on this assignment. The language is Java. I understand that I have to import a random number generator but not sure where to go from there.
The assignment is to write a program that will simulate a random walk for a given number of steps and that will compute certain statistics for the random walk. The parameters for a simulation come from standard input as a single line of parameters, consisting of (1) the initial state So; (2) the value of p; and (3) the number of steps to simulate. For example, the parameter line 5 0.40 9 specifies a simulation starting at So 5 and running for 9 steps, with p = 0.40 and q = 0.60 The output of the simulation goes to standard output. First, So is printed. As the simulation proceeds, each new state is printed, one state per line. After that, the maximum state attained, the minimum state attained, and the average of all states (including the initial state) are printed, as in the following sample output: 4 3 4 3 2 2 3 4 Maximum 5 Minimum 2 Average 3.3 Random Numbers. To complete the program, you will need a source of random num- bers. Each of the programming languages has at least one pseudo-random number genera- tor, which you are welcome to use for this purposeExplanation / Answer
/*HEADER*/
import java.util.*;
/*Class intilization*/
public class RandomNumbers
{
/*MAIN METHOD*/
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int[]numbers = new int[3];
/*LOOP*/
for(int m = 0; m < 3; m++)
{
System.out.println("Enter a number:");
/*Object Creation*/
numbers[m] = Integer.parseInt(input.nextLine());
}
/*Sorting*/
Arrays.sort(numbers);
/*Command prompt to display*/
System.out.println("Minimum number is " + numbers[0]);
System.out.println("Average number is " + numbers[1]);
System.out.println("Maximum number is " + numbers[2]);
}
}