Explanation of Solution
Program:
File name: “DistanceFromAverage.java”
//Import necessary header files
import java.util.Scanner;
//Define a class named DistanceFromAverage
public class DistanceFromAverage
{
//Define main method
public static void main(String[] args)
{
//Declare an array of values
double arr[] = new double[15];
//Declare the variables
int count=0;
double total=0;
//Create an object for Scanner class
Scanner sc = new Scanner(System.in);
//For loop to be executed until i exceeds 15
for(int i=0;i<arr.length;i++)
{
//Prompt the user to enter any 15 numbers
System.out.println("Enter a value (99999 to quit): ");
//Read the numbers
double n = sc.nextDouble();
/*The user should enter 99999 to quit entering numbers*/
if(n==99999)
{
break;
}
//Else if the user does not enter 99999
else
{
...
Trending nowThis is a popular solution!
Chapter 8 Solutions
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
- Write an application that displays the factorial for every integer value from 1 to 10. A factorial of a number is the product of that number multiplied by each positive -integer lower than it. For example, 4 factorial is 4 * 3 * 2 * 1, or 24. Save the file as Factorials.cpp.arrow_forwardA Java Practical Assignments.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View E-Sign Window Help Home Tools Java Practical Assig. x Sign In 1 /1 139% Java Practical Assignments 1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value. Prompt the user for an input value and try the Math.sqrt() method on it. The application either displays the square root or catches the thrown Exception and displays an appropriate message. 2. Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. 3. Write an application for Limpopo's Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the…arrow_forwardVariables name: Choose meaningful and descriptive names. No x, y … etc. Use lowercase. If the name consists of several words, concatenate all in one, uselowercase for the first word, and capitalize the first letter of each subsequent word inthe name. For example, the variables radius and area, and the method computeArea.3. File type: only JAVA file is allowed. Name it as Assignment2. Java5. Please add the appropriate comments for each step you add. In the top of the program, addyour name, time of starting writing the code and title of the assignment. Extra informationwould be greatarrow_forward
- Travel Tickets Company sells tickets for airlines, tours, and other travel-related services. Because ticket agents frequently mistype long ticket numbers, Travel Tickets has asked you to write an application that indicates invalid ticket number entries. The class prompts a ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you drop the last digit of the number, then divide the number by 7, the remainder of the division will be identical to the last dropped digit. Accept the ticket number from the agent and verify whether it is a valid number. Test the application with the following ticket numbers: . 123454; the comparison should evaluate to true . 147103; the comparison should evaluate to true . 154123; the comparison should evaluate to false Save the program as TicketNumber.java.arrow_forwardCreate an application that random 2 integers from 0 to 100. If a%b==0 print a/b, else rerollarrow_forwardWrite an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.cpp.arrow_forward
- . Write an application for a college’s admissions office. Prompt the user for a student’s numeric high school grade point average (for example, 3.2) and an admission test score from 0 to 100. Display the message “Accept” if the student has any of the following: A grade point average below 3.0 and an admission test score of at least 80 If the student does not meet either of the qualification criteria, display “Reject”. Save the file as Admission.java.arrow_forwardiuierarrow_forwardIn javas coding please Write a program that opens the salesdat.txt file and processes it contents. The program should display the following per store: The total sales for each week. (Should print 5 values - one for each week). The average daily sales for each week. (Should print 5 values - one for each week). The total sales for all the weeks. (Should print 1 value) The average weekly sales. (Should print 1 value) The week with the highest amount in sales. (Should print 1 week #) The week with the lowest amount in sales. (Should print 1 week #) All Values (Total Sales, Average Daily Sales for Each Week, Total Sales for all Weeks, Average Weekly Sales, Highest Amount in Sales, Lowest Amount in Sales) The file contains the dollars amount of sales that a retail store made each day for a number of weeks. Each line in the file contains thirty five numbers, which are sales numbers for five weeks. The number are separated by space. Each line in the file represents a separate store.…arrow_forward
- Write an application named, Lab14.java. This application will do the following: 1. Display an introductory message 2. Choose a random word from the file, wordlist.txt, and display it 3. Disguise the selected word, and display it 4. Ask the user whether to continue, i.e., whether to repeat steps 2, 3, and 4, or quit the application Once the user chooses to stop the application: 5. Display the total number of vowels hidden 6. Display the total number of consonants hidden 7. Display termination message The user will be asked whether to continue playing and will indicate that another game is to be played by answering ‘y’ or ‘Y’ in response to the question, “Want to play again?” asked by the program after displaying each chosen word and its disguised version. If the user’s response is any character other than ‘y’ or ‘Y’, the totals are displayed and then the application termination message is displayed. See examples below. About randomly choosing a word from the file, wordlist.txt, found on…arrow_forwardWrite an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than O or more than 10, display Score must be between 10 and O and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average. An example of the program is shown below: Enter a score >> 6 Enter another score or 99 to quit >>» 7 Enter another score or 99 to quit >» 9 Enter another score or 99 to quit >» 7 Enter another score or 99 to quit >> 99 4 valid scores were entered Highest was 9 Lowest was 6 Average was 7.25arrow_forwardWhat is the output displayed when the button is clicked?arrow_forward
- 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