
For this project I have to print 10 random numbers from (0-99), print the max value, the average of the ten numbers, print the first index at which the maximum of the array occurs, and create an array b which has the same values as a only in reverse order, and print out the first 10 values of b. basically the output should be similar to this: Average=47.59 Maximum value=98 Index of maximum=44 First 10 components of b: 71 5 22 57 23 16 14 68 80 23
This is the code i attempted, but i am having trouble putting it together in order to make sence.. any solutions:
import java.util.Random; import java.util.Scanner; public class ArrayRandom{ public static void main(String args[]){ Random r = new Random(); int array [] = new int[100];
for(int i = 0; i <100; i++){
array[i] = r.nextInt(100) + 1;
}
System.out.println("First 10 components of b: ");
for(int i = 0; i <10; i++){
System.out.print(array[i] + " ");
}
}
public int sum( int[] array ){
int sum = 0;
for( int i = 0; i < array.length; i++ ){
sum += array[i];
}
int average= sum/10;
System.out.println("Average: "+ average);
}
public static void main (String[] args){
let max = array[0]
for(i in array)
if i > max
max = i
System.out.println(Math.max(RA);
}
}

import java.util.Random;
public class ArrayRandom{
public static void main(String args[]){
Random r = new Random();
int array [] = new int[10];
for(int i = 0; i <array.length; i++){
array[i] = r.nextInt(100) + 1;
}
int sum = 0;
int max = array[0];
int index=0;
for( int i = 0; i < array.length; i++ ){
sum += array[i];
if( array[i] > max){
max = array[i];
index=i;
}
}
int average= sum/10;
System.out.println("Average is: "+ average);
System.out.println("Maximum Number is: "+ max);
System.out.println("Index of max number is: "+ index);
System.out.println("First 10 components of b: ");
for(int i = array.length-1; i >=0; i--){
System.out.print(array[i] + " ");
}
}
}