Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
8th Edition
ISBN: 9781337091480
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 12, Problem 4PE
Program Plan Intro
Program Plan
1. Variables mentioned below are used:
- arrSize- the size of the array as the input given by the user.
- values[]- which has the series of numbers to be sorted
- input- double number entered as input by the user
- avgValue − an average of all the numbers entered as input
- exitVal- exit code to quit the reading of input from the console.
- sum- the sum of all the entered numbers and is used to calculate the average of numbers.
- arrCreateStatus − a boolean value that decides whether to create an array with user-entered sized.
- valid- boolean value that holds the status of reading input from the console.
2. Functions mentioned below are used:
- main()- Main function of the program which gets the input and displays the output.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
this practice assignement wants me to Write an application that contains an array of 10 multiple-choice quiz questions related to your favorite hobby. Each question contains three answer choices. Also create an array that holds the correct answer to each question—A, B, or C. Display each question and verify that the user enters only A, B, or C as the answer—if not, keep prompting the user until a valid response is entered. If the user responds to a question correctly, display Correct!; otherwise, display The correct answer is and the letter of the correct answer. After the user answers all the questions, display the number of correct and incorrect answers
here is my new code! i need help to get it to working :
import java.util.*;public class Quiz {public static void main(String args[]){String questions[]=("1.What is my favorite hobby?\n" + "(a)hair\n(b)makeup\n(c)both a and b\n", "2.Who first discovered makeup?\n" +"(a)Egyptians\n(b)haitians\n(c)Africans", "3.What glue is best to use…
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.…
Chapter 12 Solutions
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
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
- Make 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_forwardThe local driver’s license office has asked you to create an application that grades the written portion of the driver’s license exam. The exam has 20 multiple-choice questions. Here are the correct answers: B D A A C A B A C D B C D A D C C B D A Your program should store these correct answers in an array. The program should read the student’s answers for each of the 20 questions from a text file and store the answers in another array. (Create your own text file to test the application.) After the student’s answers have been read from the file, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions. Need Visual Studio Code (C Language )arrow_forwardthis practcie assignment wants me to Write an application that contains an array of 10 multiple-choice quiz questions related to your favorite hobby. Each question contains three answer choices. Also create an array that holds the correct answer to each question—A, B, or C. Display each question and verify that the user enters only A, B, or C as the answer—if not, keep prompting the user until a valid response is entered. If the user responds to a question correctly, display Correct!; otherwise, display The correct answer is and the letter of the correct answer. After the user answers all the questions, display the number of correct and incorrect answers . how do i create arrays help!! here is my code that i have so far : import java util.Scanner;public class Quiz {public static void main(String[] args) {Scanner input = new Scanner(System.in);System.out.println("What is my favorite hobby?\n" + "(a)hair\n(b)makeup\n(c)both a and b\n");System.out.println("Who first discovered makeup?\n"…arrow_forward
- In C#, Write a program named CheckZips that is used by a package delivery service to check delivery areas. The program contains an array that holds the 10 zip codes of areas to which the company makes deliveries. (Note that this array is created for you and does not need to be changed.) Prompt a user to enter a zip code, and display a message indicating whether the zip code is in the company’s delivery area. For example if the user enters a zip code in the array, such as 60007, the output should be Delivery to 60007 ok. If the user enters a zip code not in the array, such as 60008, the output should be Sorry - no delivery to 60008.arrow_forwardYou are a manager of a Wally's Training Gym and you encourage your trainers to enroll new members. Input is the trainer's last name and the number of new enrollees. Output is the number of trainers who have enrolled members in each of three categories: 0-5 new members, 6-10 new members, and 11 to 15 new members. Write an application that allows the user to enter 15 Trainer's names and the number of new members they have enrolled into an array. Output is to display the number of trainers who are in each category. Use good programming techniques that you have learned throughout the course. Use appropriate variable names, use an array to store the names and number of new enrollees, and use prompts for the input and labels with the display. Turn in your Raptor file by clicking on the Start Here button in the upper right corner of your screen.arrow_forwardYou are a manager of a Wally's Training Gym and you encourage your trainers to enroll new members. Input is the trainer's last name and the number of new enrollees. Output is the number of trainers who have enrolled members in each of three categories: 0-5 new members, 6-10 new members, and 11 to 15 new members. Write an application that allows the user to enter 15 names and the number of new members they have enrolled into an array. Output is to display the number of trainers who are in each category. Use good programming techniques that you have learned throughout the course. Use appropriate variable names, use an array to store the names and number of new enrollees, and use prompts for the input and labels with the display.arrow_forward
- Write 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_forwardPlease written by computer sourcearrow_forwardNeed help coding in Java Write an application that stores at least five different college courses (such as CIS101), the time it first meets in the week (such as Mon 9 am), and the instructor (such as Johnson) in a two-dimensional array. Allow the user to enter a course name and display the corresponding time and instructor. If the course exists twice, display details for both sessions. If the course does not exist, display Invalid Entry: No Such course. Use the following values: Course Time Instructor CIS101 Mon 9 am Farrell CIS210 Mon 11 am Patel MKT100 Tues 8:30 am Wong ACC150 Tues 6 pm Deitrich CIS101 Fri 1 pm Lennonarrow_forward
- Using Java Scriptarrow_forwardI have a very short time, I would like it to be resolved quickly :) It is very important to me. Homework will be solved with visual studio c# program.arrow_forwardWrite a C# console application named MaxMin that asks the user to enter 5 integers, representing the test scores of 5 students. For each input score, you need to check and make sure it is valid (i.e., in between 0 and 100). Store the 5 integers in an int array, and then find and display the highest and the lowest scores on the screen. For example, if you have the 5 scores as {85, 72, 65, 98, 80}, then the output message should be "The highest score is 98, and the lowest score is 65". Hint: use a while loop.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,