Below is code which defines and creates an Array, myList: int [] myList = new int [5]; //define and createThe loop below stores the values 1 to 5 in myList:for (int i = 0; i < 5; i ++) {myList [ i ] = i + 1; //store values using a loop}The loop below prints the values from first to last in myList:for (int i = 0; i < myList.length; i++) { System.out.print(myList [ i ] + " ");}The code below is used to get user from the user and calculate the sum:import java.util.*;public class WhileWithInput {public static void main(String[] args) {Scanner reader = new Scanner (System.in);int count = 1; double total = 0; while (count <= 5) {System.out.println("Enter a decimal number"); double number = reader.nextDouble();total = total + number;count = count + 1;System.out.println("The total is " + total); }System.out.println("The total is " + total); }}1CPS 2231 Chapter 7 – lab 2 Fall 2019Use the examples on page 1 to complete the lab below. Please submit a screen print of the Eclipse editor showing your code and output with answers:Write a Java class, XXX_Lab75, where XXX is your Kean email ID. The class will do the following:1) Consist of two methods: a. mainb. printHigherThanAveragepublic static void printHigherAverage(double [] numbers, double avg)The method will print all the numbers in the array, numbers, which are higher than the average.2) In the main methods, create an Array which can contain 5 elements of type double3) In a loopa. Ask the user for 5 values using a Scanner. b. Store the values in the arrayc. Sum the values4) At the end of the loop:a. Calculate the average.b. Call the method printHigherAverage and pass it the array andthe average.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Below is code which defines and creates an Array, myList: int [] myList = new int [5]; //define and create
The loop below stores the values 1 to 5 in myList:
for (int i = 0; i < 5; i ++) {
myList [ i ] = i + 1; //store values using a loop
}
The loop below prints the values from first to last in myList:
for (int i = 0; i < myList.length; i++) { System.out.print(myList [ i ] + " ");
}
The code below is used to get user from the user and calculate the sum:
import java.util.*;
public class WhileWithInput {
public static void main(String[] args) {
Scanner reader = new Scanner (System.in);
int count = 1; double total = 0; while (count <= 5) {
System.out.println("Enter a decimal number"); double number = reader.nextDouble();
total = total + number;
count = count + 1;
System.out.println("The total is " + total); }
System.out.println("The total is " + total); }
}
1
CPS 2231 Chapter 7 – lab 2 Fall 2019
Use the examples on page 1 to complete the lab below. Please submit a screen print of the Eclipse editor showing your code and output with answers:
Write a Java class, XXX_Lab75, where XXX is your Kean email ID. The class will do the following:
1) Consist of two methods: a. main
b. printHigherThanAverage
public static void printHigherAverage(double [] numbers, double avg)
The method will print all the numbers in the array, numbers, which are higher than the average.
2) In the main methods, create an Array which can contain 5 elements of type double
3) In a loop
a. Ask the user for 5 values using a Scanner. b. Store the values in the array
c. Sum the values
4) At the end of the loop:
a. Calculate the average.
b. Call the method printHigherAverage and pass it the array and
the average.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage