Java Programming, Loose-Leaf Version
9th Edition
ISBN: 9781337685900
Author: FARRELL, Joyce
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 8, Problem 4PE
Program Plan Intro
ArrayMethodDemo
Program plan:
ArrayMethodDemo.java
- Create a class named “ArrayMethodDemo”. Inside the class,
- Define the “main ()” method.
- Create and define the array.
- Declare and define the required variable and methods.
- Define the method “display ()”
- Display the numbers present in the array.
- Define the method “displayReverse ()”
- Display the numbers present in the array in the reverse order.
- Define the method “displaySum ()”
- Define the required variables.
- Use loop to iterate and compute the sum of the array elements.
- Display the sum.
- Define the method “displayLessThan ()”
- Loop that iterates for the array elements present.
- Use condition to validate the values of the array and limit.
- Display the numbers less than the limit value
- Define the method “displayHigherThanAverage ()”
- Declare and define the required variables.
- Loop that iterates to compute sum of the array elements.
- Compute the average.
- Display the average.
- Loop that iterates for the array elements present.
- Use condition to validate the values of the array and average.
- Display the numbers greater than average.
- Define the “main ()” method.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Create an application containing an array that stores eight integers. The application should call five methods that in turn
(1) display all the integers,
(2) display all the integers in reverse order ,
(3) display the sum of the integers,
(4) display all values less than a limiting argument, and
(5) display all values that are higher than the calculated average value.
Java:
Can you write it in Java, add comments
Create an application containing an array that stores eight integers. Prompt the user to enter the 8 integers. The application should call five methods that in turn (1) display all the integers, (2) display all the integers in reverse order, (3) display the sum of the integers, (4) display all values less than the calculated average value, and (5) display all values that are higher than the calculated average value. Save the file as ArrayMethodDemo
Chapter 8 Solutions
Java Programming, Loose-Leaf Version
Knowledge Booster
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
- write a (GUI) application that asks a user how many integers to be entered, then stores the integers in an array. Allow the user to enter all or a portion of the total integers. Display the integers from first to last, and then display the integers from last to first. Display the minimum and maximum numbers as well as the total and average of the numbers.arrow_forwardDesign an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data for each object, and then display all the values.arrow_forwardCreate an application containing an array that stores eight integers. The application should call five methods that in turn: Display all the integers Display all the integers in reverse order Display the sum of the integers Display all values less than a limiting argument Display all values that are higher than the calculated average value. Here is the given code: public class ArrayMethodDemo { publicstaticvoidmain (Stringargs[]) { int[] numbers = {12,15,34,67,4,9,10,7}; int limit =12; display(numbers); displayReverse(numbers); displaySum(numbers); displayLessThan(numbers, limit); displayHigherThanAverage(numbers); } publicstaticvoiddisplay(int[] numbers) { // Write your code here } publicstaticvoiddisplayReverse(int[] numbers) { // Write your code here } publicstaticvoiddisplaySum(int[] numbers) { // Write your code here } publicstaticvoiddisplayLessThan(int[] numbers,intlimit) { // Write your code here } publicstaticvoiddisplayHigherThanAverage(int[] numbers) { // Write your…arrow_forward
- Java: Implement the ArrayMethodDemo application containing an array that stores eight integers. The application should call the following five methods: display - should display all the integers displayReverse - should display all the integers in reverse order displaySum - should display the sum of the integers displayLessThan - should display all values less than a limiting argument displayHigherThanAverage - should display all values that are higher than the calculated average value. Code: public class ArrayMethodDemo { public static void main (String args[]) { int[] numbers = {12, 15, 34, 67, 4, 9, 10, 7}; int limit = 12; display(numbers); displayReverse(numbers); displaySum(numbers); displayLessThan(numbers, limit); displayHigherThanAverage(numbers); } public static void display(int[] numbers) { // Write your code here } public static void displayReverse(int[] numbers) { // Write your…arrow_forwardWrite an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the user to enter a numeric test score for the student. Create a ScoreException class, and throw a ScoreException for the class if the user does not enter a valid score (less than or equal to 100). Catch the ScoreException and then display an appropriate message. In addition, store a 0 for the student’s score. At the end of the application, display all the student IDs and scores. Save the files as ScoreException.java and TestScore.java.arrow_forwardJAVA I cannot figure this one out no matter what I do I cannot get it to run. Please write it in a student way not in an too advance way. Write an application containing three parallel arrays that hold 10 elements each. The first array hold four-digit student ID numbers, the second array holds first names, and the third array holds the students’ grade point averages. Use dialog boxes to accept a student ID number and display the student’s first name and grade point average. If a match is not found, display an error message that includes the invalid ID number and allow the user to search for a new ID number.arrow_forward
- Creating Enumerations In this section, you create two enumerations that hold colors and car model types. You will use them as field types in a Car class and write a demonstration program that shows how the enumerations are used. 1. Open a new file in your text editor, and type the following Color enumeration: enum Color {BLACK, BLUE, GREEN, RED, WHITE, YELLOW}; 2. Save the file as Color.java. 3. Open a new file in your text editor, and create the following Model enumeration: enum Model {SEDAN, CONVERTIBLE, MINIVAN}; 4. Save the file as Model.java. Next, open a new file in your text editor, and start to define a Car class that holds three fields: a year, a model, and a color. public class Car { private int year; private Model model; private Color color; 5. Add a constructor for the Car class that accepts parameters that hold the values for year, model, and color as follows: public Car(int yr, Model m, Color c) { year = yr; model = m; color = c; } 6. Add a display()…arrow_forward1. Create an java program containing an array that stores 20 prices, such as $2.34, $7.89, $1.34, and so on. The application should -display the sum of all the prices, -display all values less than $5.00, -calculate the average of the prices, and -display all values that are higher than the calculated average value.arrow_forwardWrite a java application which initializes an array with ten random integers between 1 and 6. Write two methods: 1. arraySwap: this method should accept an integer array and swap the first and the last item. 2. findMinimum: this method should accept the array and return the minimum value of that array You should comment and follow javaDoc for both methods. Your main method should test each of these methods.arrow_forward
- Create a program that will track student names and their grades and perform some simple statistics. In a main class create an ArrayList or array that will hold Student names. Create a second (parallel) ArrayList or array that will hold student scores, represented as integers from 0-100. Prompt the user to enter some students (for your purposes, enter information for at least three). Then present a menu for the user. The menu will contain the following options: Find student with the highest grade (print out the name of the student) Find grade average (return the grade average back to the calling method) print information of all students exit program Create methods in your main class for these options. Keep the your ArrayList or array inside your main method and pass it to the other methods; it should not be a global variable. Validate the grade; the user should not enter anything below 0 or above 100.arrow_forwardplease write in javaarrow_forwardCreate an array of objects of the Person class, of size 4. Create three objects of the Person class, with values, and assign the objects to the array. Loop through the array and print the name, job, and email of all Personobjects. (using the Netbeans application)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage