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

Write a program that allows the user to enter an integer n, and then generates n

ID: 3832336 • Letter: W

Question

Write a program that allows the user to enter an integer n, and then generates n ransom n random number between 1 and 100. The program calculates and prints the sum, average, and the number above the average. Draw the flowchart for the program on the back of this paper. Open TextPad and save the source file on the desktop using the file name as lastname_final write your name on the first line of the source file, and short comment for each task in the program. Leave the TextPad open and this paper on the keyboard when you finish each in the program. the exam. An output example:

Explanation / Answer

package sample1;

import java.util.Random;
import java.util.Scanner;

public class test
{
   public static void main(String args[]){
       System.out.println("enter n : ");
   Scanner s = new Scanner(System.in);
   int n=s.nextInt();
   double avg=0.0;
   int sum=0;
   Random r = new Random();
   int arr[]=new int[n];  
   for(int i=0;i<n;i++){
       arr[i]=r.nextInt(100)+1;
       sum+=arr[i];
   }
   avg=sum/n;
   System.out.println("Sum : "+sum);
   System.out.println("Average :"+avg);
   System.out.println(" Numbers above average are ---");
   for (int i=0;i<n;i++){
       if(arr[i]>avg)
       System.out.println(arr[i]);
   }
}
}

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