Question
JAVA Experiment 2: Actual Combat of Array Common Algorithms You need the array_labs directory, which contains the experiment code, provided by the teacher, please put
JAVA Experiment 2: Actual Combat of Array Common Algorithms You need the array_labs directory, which contains the experiment code, provided by the teacher, please put this folder under package chapter3. Activity 1: Cumulative summation of array elements Write a program that allows users to enter 5 numbers, and then calculate their average value and the number of numbers greater than the average value. The program effect is as follows:
The basic structure of the program is shown below, complete with other codes to achieve the above functions.
public class AnalyzeNumbers { public static void main(String[] args) { Scanner input = new Scanner( System.in); System.out.println("Enter 5 numbers:"); //Decalare an array to store user input int[] nums = new int[5]; nums[0] = input.nextInt(); nums[1] = input.nextInt(); nums[2] = input.nextInt(); nums[3] = input.nextInt(); nums[4] = input.nextInt();
//other codes
}
}
Enter 5 numbers: 65 89 67 77 56 Average of all numbers is: 70.8 Number of elements above average is: 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started