JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
9th Edition
ISBN: 9780357616673
Author: FARRELL
Publisher: CENGAGE L
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 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)
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 PROGRAM(LL)+MINDTAP (1 TERM) V2.0
Knowledge Booster
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_forwardAllow 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_forwardAlert dont submit AI generated answer. In java please, and would you put comments so I can know what you did. answer both question 1 and 2.arrow_forward
- please write in javaarrow_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_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
- Write 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_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_forwardIn the composer array, create a statement that copies the string "Beethoven."arrow_forward
- Please assist with the attached question using Java language. Thanks.arrow_forwardMake 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. Make 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, display the message Score over 100, and then store a 0 for the student's score. At the end of the application, display all the student IDs and scores. public class ScoreException extends Exception { public ScoreException(String s) { } } import java.util.*; public class TestScore { public static void main(String args[]) throws Exception { Scanner input = new Scanner(System.in); int[] ids = {1234, 2345, 3456, 4567, 5678}; int[] scores = {0, 0, 0, 0, 0}; String scoreString = new String(); final int HIGHLIMIT = 100; String inString, outString = ""; for (int x = 0; x < ids.length; ++x)…arrow_forwardCreate 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.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,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,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage