Question
Ask the user for 5 integers (one at a time), filling the array with the 5 integers.
Find the sum of the 5 integers.
Find the average of the 5 integers.
Find the product of the 5 integers.
Display, with a message, the 5 integers, their sum, average, and product to the screen.
Make sure you use loops for all input and calculations.
Submit your source code as a plain text file with a .java extension.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
import java.util.Scanner;public class ArrayLoop {
public static void main(String[] args){
// initialize an integer array of 5 elements
int array[] = new int[5];
// initialize the scanner that will be used for user input
Scanner inputScanner = new Scanner(System.in);
// ask the user for 5 integer numbers and store them in the array
for (int i=0; i < 5; i++){
// prompt the user for input
System.out.print("Please input an integer number:");
// get user input
String userInput = inputScanner.next();
// convert the user input to an integer and store it to the array
array[i] = Integer.parseInt(userInput);
}
// initial values for sum and product of integers
int sum = 0;
int product = 1;...