Java Programming, Loose-Leaf Version
9th Edition
ISBN: 9781337685900
Author: FARRELL, Joyce
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 8, Problem 1PE
Explanation of Solution
Program:
File name: “NineInts.java”
//Import necessary header files
import java.util.Scanner;
//Define a class named NineInts
public class NineInts
{
//Define main method
public static void main(String[] args)
{
//Create an object for Scanner class
Scanner sc= new Scanner(System.in);
//Declare an array of integers
int[] num = new int[9];
//Prompt the user to enter nine integers
System.out.print("Enter nine integers: ");
for(int i=0;i<9;i++)
{
num[i]=sc.nextInt();
}
//Print the numbers from first to last
System...
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Write an application that stores the following nine integers in an array: 10, 15, 19, 23, 26, 29, 31, 34, 38. Display the integers from first to last, and then display the integers from last to first.
Write an application that stores nine integers in an array. Display the integers from first tolast, and then display the integers from last to first.
Create an application that contains an enumeration (enum) that represents the days of the week. Display a list of the days, then prompt the user for a day. Display business hours for the chosen day. Create your own business hours stored in an array; however, every day of the week should have different hours. Although companies do not normally have different business hours every day of the week, programming your code with this difference will help in finding and fixing coding errors.
java program
Chapter 8 Solutions
Java Programming, Loose-Leaf Version
Knowledge Booster
Similar questions
- Write an application that prompts the user to enter nine integers and then store those nine integers in an array. Display the integers from first to last, and then display the integers from last to first. You do not have to sort them, just display the order entered and the reverse order entered. (In JAVA)arrow_forwardWrite an application that stores the following nine integers in an array called numbers: 10, 15, 19, 23, 26, 29, 31, 34, 38. Display the integers from first to last, and then display the integers from last to first.arrow_forwardWrite an application that stores the following nine integers in an array: 10, 15, 19, 23, 26, 29, 31, 34, 38. Display the integers from first to last, and then display the integers from last to first. ***can you provide comments explaining your methods? Thank you for all of your help ^_^arrow_forward
- 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. java programarrow_forwardJAVA 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_forwardJAVA Create an application that contains an enumeration (enum) that represents the days of the week. Display a list of the days, then prompt the user for a day. Display business hours for the chosen day. Create your own business hours stored in an array; however, every day of the week should have different hours. Although companies do not normally have different business hours every day of the week, programming your code with this difference will help in finding and fixing coding errors.arrow_forward
- Create 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_forwardCan 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 ArrayMethodDemoarrow_forwardwrite 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_forward
- Allow a user to enter any number of double values up to 15. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display each entered value and its distance from the average. Save the file as DistanceFromAverage.java. Now, modify that program to first prompt the user to enter an integer that represents the array size. Java generates a NumberFormatException if you attempt to enter a noninteger value using nextInt(); handle this exception by displaying an appropriate error message. Create an array using the integer entered as the size. Java generates a NegativeArraySizeException if you attempt to create an array with a negative size; handle this exception by setting the array size to a default value of five. If the array is created successfully, use exception-handling techniques to ensure that each entered array value is a double before the program calculates each element’s distance from the average.…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_forwardWrite a Java application and use a two-dimensional array that will store the five top artist sales for 2017. The application must also hold the artist sales for CDs, DVDs and BLU RAY items.Your program must: Q.1.1 Create a two-dimensional array to contain the three sale items for five different artists. A single array must be used to store the artist names. Q.1.2 Allow a user to enter in a number, ranging from 1 to 5, which will represent the artist position with regards to the album sales.Q.1.3 Printout the artist name including the CD, DVD, BLU RAY sales amounts and total sales.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT