Question

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 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;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

ChatBot Using Java Programming
Homework Solution
$7.00
Java
Programming
Coding
Chatting
Bot
Users
Computers
Sentences
Symbols
Instant Messaging
Input
Output
Special Characters
Even Numbers
Odd Numbers
From BS Tree to AVL Tree in Java
Homework Solution
$20.00
Java
Programming
Codes
Algorithms
Binary Search Tree
AVL Tree
Search Operation
Logarithmic Time
Rebalancing
Loops
Statements
Variables
Successors
Ancestors
Parents
Nodes
Edges
Boolean Values
Data Structures
Java Program For Vending Machine
Homework Solution
$40.00
Java
Programming
Computer Science
Vending Machine
Drinks
Password
Screen
Inventory
Menu
Errors
Money
Java Project: Right Triangle Of Stars
Homework Solution
$30.00
Java
Programming
Computer Science
Mathematics
Loops
Input
Output
Conditions
Right Triangle
Base
Hypotenuse
Stars
Statements
Variables
Even Numbers
Odd Numbers
Transformations
World Puzzle Problem & Arrays in Java
Homework Solution
$60.00
Java
Programming
Codes
Algorithms
Arrays
Word Puzzles
Input
Output
Running Time
Integers
Loops
Maximum Count
Divide And Conquer Method
Statements
Variables
Recursive Calls
Get help from a qualified tutor
Live Chats