Please, help me I'm a novice programmer.
I trying to make an array with random numbers and print the maximum, minimum, and average values.
To generate a random number, use the Math.random()
method, which returns a value in the range [0, 1]
.
public class Main {
public static void main(String[] args) {
int a = 99;
double[] array = new double[a];
int b;
for(b = 0; b < array.length; ++b) {
}
array[b] = Math.random();
double max = array[0];
double min = array[0];
double abg = 0.0D;
for(b = 0; b < array.length; ++b) {
}
if (max < array[b]) {
max = array[b];
}
if (min > array[b]) {
min = array[b];
}
abg += array[b] / (double)array.length;
System.out.println("max = " + max);
System.out.println("min = " + min);
System.out.println("abg = " + abg);
}
}