QuestionQuestion

Create an integer array of 5 elements.

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 PreviewSolution 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;...
$40.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats