Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help on java on H/W. Thanks Write a program that uses an array to find the

ID: 3803653 • Letter: N

Question

Need help on java on H/W. Thanks

Write a program that uses an array to find the Average of 10 double values. Use Math. random() in combination with a for loop to fill the array with 10 random values. Then use a different for loop to iterate through the array when summing the total for all 10 double values. Attach Snipping photos of source code and output. If you are comfortable with Arrays, try to implement the same exercise using ArrayList. Note the difference between ArrayList and Array implementation.

Explanation / Answer

import java.lang.*;
import java.util.*;

public class Avergae{

public static void main(String []args){

double ar[] = new double[10];
double sum = 0.0;
double average;
  
Syste,.out.println("Random numbers");
for(int i =0;i<10;i++)
{
ar[i] = Math.random()*100;
}
  
for(int j= 0;j<10;j++)
{
sum = sum + ar[j];
}
  
average = sum/10;
  
System.out.println("The average of numbers is"+ average);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote