Question

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. Save the file as DistanceFromAverageWithExceptionHandling.java.

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: How do you create a a python program that implements the following functions  get_top_card(card_...

A: Actually, python is a easiest programming language. It is a platform independent.  

Q: What is software design pattern? What are the three categories we have in the design pattern?

A: It is a general solution that is able to be used more than once for commonly occurring problem in so...

Q: p.s :see image for question.

A: #include <iostream> double computeX_Avg(double F[],double X[],int n); using namespace std; int...

Q: Write a program that prompts the user to enter 50 integers and stores them in an array. The program ...

A: Program Plan:- 1. Initialise all the required header files. 2. declare the array of 50 numbers. 3. a...

Q: In this assignment, you are required to write a bash script, call it mycontainer.sh to do the follow...

A: The, answers are given below:

Q: CSC 235.S70 (Fall 2020) Homework #4 Due: 12/10/20) (Given 11/24/20 Following is a data description o...

A: Actually, database is a used to stores the data.

Q: Solve this algbra

A: Actually,  Consider the machine number is 0     01100000111     010100110001

Q: What is a firewall? What are the three types of Firewalls?

A: A firewall is a network security device that advising the incoming and outgoing network traffic and ...

Q: When selecting recipients from an Excel workbook, the source is specified as a(n) typed list contact...

A: C) Existing List

Q: 2. Modify the Fahrenheit program so that it displays a button that when pressed causes theconversion...

A: Actually, java is a object oriented programming language. It is a platform independent.

Q: Consider the functional dependency of relation R (A, B, C,D) F = {A→BC, B→C, A→B, AB→D} Compute clos...

A: Closure Set of F+ is: A→A, A→B,A→C, B→B, B→C,C→C, D→D, AB→A, AB→B, AB→C, AC→A, AC→B, AC→C, AD→A,AD→B...

Q: Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Re...

A: The, given information is:  A file that contains a list of at least 15 six-digit account numbers. Re...

Q: (Fall 2020) (Given 11/24/20 Homework #4 Due: 12/10/20) Following is a data description of a library:...

A: Actually, database is used to stores the data.

Q: Give the transition diagram of a standard Turing Machine that implements the function. Briefly expla...

A: Actually, transition is a changing from one state to another.

Q: C++ Student Data Write a program that uses two structures Name and Student to store the following in...

A: Actually, given information about students: Create a nameType structure that consists of First Name...

Q: Write a C program, called msg.c, that reads messages from an input file (or stdin) and verifies whet...

A: C programming is a general-purpose, procedural, imperative computer programming language developed i...

Q: Write the SQL statements for the following User table. User_id Name City Order_date Purchase_amount ...

A: To create a table in SQL, create table command is used. Ans 1. The required query is: CREATE TABLE U...

Q: The IT director of Global Hills started the meeting today by saying “I’ve got some good news andsome...

A: 1. Some of the constraints associated with the system's growth are:- By the end of November, the fra...

Q: Evaluate the following statement: DOM is a limited interface which works only on JavaScript and HTML...

A: he HTML DOM model is constructed as a tree of Objects: The HTML DOM Tree of Objects With the obje...

Q: Write a C program, called msg.c, that reads messages from an input file (or stdin) and verifies whet...

A: #include <stdio.h>#include<string.h>#include<stdbool.h>bool foo(char msg[120]);boo...

Q: Draw the diagram of given addressing mode. Show it with examples also. 1.  Nested Indirect Addressin...

A: In  Nested Indirect Addressing mode, the address of the operand which is needed to be used in the in...

Q: Convert the following C++ programs into Pep/9 assembly 1) #include Using namespace std; void minimu...

A: //1) Converting the given C++ program into the Assembly language code MEMORY ADDRESS MNEMONICS CO...

Q: When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling...

A: Program Plan:- 1. Create the class Process. 2. Define all the following functions:- sertBack(Proces...

Q: Design an algorithm and hence, a logic using C language, based on STM32F100RB peripherals to follow ...

A: Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certa...

Q: Compiler Construction

A: Actually, compiler is a special program that turns the code into machine language.

Q: Hello, How can I do this : Modify the program and use the strtok function to count the number of wor...

A: Click to see the answer

Q: Write a class named StockPrices . The class constructor should accept an array of stock prices as it...

A: public class StockPrices { double stockPrices[];  public StockPrices(double prices[]) {  this.stockP...

Q: Computer Science Question

A: The given password:  R@pt0r As per text: for first character: 4 bits of entropy for next characters:...

Q: in c programming

A: #include <stdio.h># define MAX_SIZE 5000 int main(void){    int N;    int num,c;    int a[MAX_...

Q: void fun1() { float a; void fun2() { int b, c; <-- 1 The calling sequence for this program for execu...

A: Actually, function is a group of statements.

Q: How should i use github?What are the best hacking apps for Android?Can I earn through canva and remo...

A: GitHub GitHub is a highly used software that is typically used for version control. It is helpful wh...

Q: Determine the relationships between aggregation, generalization, and association.

A: Aggregation: Aggregation is a type of association that occurs when a class is generated as a group ...

Q: Java GUI (Calculator) Program

A: // Java program to calculate // double integral value class GFG{  // Change the function according t...

Q: Question-3 There are n number of students in a class. Assume a teacher enters and wants to shake han...

A: Solution is in Step 2.

Q: Decode J mpwf zpv

A: Decode J mpwf zpv I love you

Q: Clustering is a side effect of linear probing. Group of answer choices True False Also explain why?

A: The, answer has given below;

Q: please use c++ to answer the following question Use inheritance and classes to represent a deck of p...

A: Actually, inheritance is a acquiring the properties from one class to another class.

Q: Write an ALP for 8051 to transfer letter “ABC” serially at 4800 baud continuously. Use 8-bit data an...

A:   Algorithm – Load 00H in a register (for carry) Load content from memory into register pair Move ...

Q: What is a computer virus? What is a worm?

A: VIRUS stands for Vital Infection Resources Under Sieze A computer virus, much like a flu virus, is d...

Q: (This if for mindtap on cengage, if not possible, use devc++ 5.11 but mindtap is more accurate) Writ...

A: int smallestIndex(int array[], int size) { int smallest = array[0], index = 0;  for(int i = 0; i &lt...