This program will not require any IF statements, loops, or custom classes. Instead, it will check...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This program will not require any IF statements, loops, or custom classes. Instead, it will check inputted data for two kinds of mistakes: Wrong data type (entering text instead of numbers), and math errors (division by zero). The program is intended to be used by an employee to calculate the number of routes a driver will need to follow to deliver all of their packages. Create the following variables for use by the program. Data Entry Requirements: Number of packages (int) Number of destinations (int) Number of routes to be driven (int) Tip: When working with Try/Catch blocks, all variables must be initialized by setting each one equal to zero when it is declared, like this: Normal: int someVariable; Initialized: int someVariable = 0; User prompts, output messages, and error messages: 1. "Please enter the number of packages:" (inputs to the variable containing the number of packages) 2. "Please enter the number of destinations:" (inputs to the variable containing the number of destinations) 3. "Calculating routes..." (displayed after the program receives the second input) 4. "Number of routes:" (final output message) 5. "Error! Please enter only numbers." (error message for both data entry handlers) 6. "Error! Cannot have zero destinations." (error message for route calculation) Note: The specific wording shown above is required by the customer and must be followed precisely, including punctuation. 1. Prompt the user to enter the number of packages. 2. Check to ensure that the user enters a number and not another character. (use Try) 3. Provide an error message in case they entered a character that's not a number. (use Catch with InputMismatchException) 4. Repeat the above steps to have the user enter the number of destinations. 5. Calculate the number of routes by setting the last variable equal to the number of packages divided by the number of destinations. (Try) 6. Provide an error message in case the user entered a zero for the number of destinations, which would cause a divide-by-zero error. (Catch with ArithmeticException) 7. Output the number of routes to the screen. (Will display as zero if an error message is thrown.) Suggested input values for Debug mode (no errors): 6 2 Expected output for above sample: Please enter the number of packages: 6 Please enter the number of destinations: 2 Calculating routes.... Number of routes: 3 Suggested input values for testing error messages: 6 0 Expected output for above sample: Please enter the number of packages: 6 Please enter the number of destinations: 2 Calculating routes... Number of routes: 3 412926.1696728.qx3zqy7 LAB ACTIVITY 10.1.1: Unit 5 Lab Assignment LabProgram.java 1 import java.util.*; 2 3 public class LabProgram { public static void main(String[] args) { /* Type your code below this line. Create additional lines as needed. */ 4 5 6 7 8 } // do not delete this line 9 // do not delete this line 10 0/7 Load default template... This program will not require any IF statements, loops, or custom classes. Instead, it will check inputted data for two kinds of mistakes: Wrong data type (entering text instead of numbers), and math errors (division by zero). The program is intended to be used by an employee to calculate the number of routes a driver will need to follow to deliver all of their packages. Create the following variables for use by the program. Data Entry Requirements: Number of packages (int) Number of destinations (int) Number of routes to be driven (int) Tip: When working with Try/Catch blocks, all variables must be initialized by setting each one equal to zero when it is declared, like this: Normal: int someVariable; Initialized: int someVariable = 0; User prompts, output messages, and error messages: 1. "Please enter the number of packages:" (inputs to the variable containing the number of packages) 2. "Please enter the number of destinations:" (inputs to the variable containing the number of destinations) 3. "Calculating routes..." (displayed after the program receives the second input) 4. "Number of routes:" (final output message) 5. "Error! Please enter only numbers." (error message for both data entry handlers) 6. "Error! Cannot have zero destinations." (error message for route calculation) Note: The specific wording shown above is required by the customer and must be followed precisely, including punctuation. 1. Prompt the user to enter the number of packages. 2. Check to ensure that the user enters a number and not another character. (use Try) 3. Provide an error message in case they entered a character that's not a number. (use Catch with InputMismatchException) 4. Repeat the above steps to have the user enter the number of destinations. 5. Calculate the number of routes by setting the last variable equal to the number of packages divided by the number of destinations. (Try) 6. Provide an error message in case the user entered a zero for the number of destinations, which would cause a divide-by-zero error. (Catch with ArithmeticException) 7. Output the number of routes to the screen. (Will display as zero if an error message is thrown.) Suggested input values for Debug mode (no errors): 6 2 Expected output for above sample: Please enter the number of packages: 6 Please enter the number of destinations: 2 Calculating routes.... Number of routes: 3 Suggested input values for testing error messages: 6 0 Expected output for above sample: Please enter the number of packages: 6 Please enter the number of destinations: 2 Calculating routes... Number of routes: 3 412926.1696728.qx3zqy7 LAB ACTIVITY 10.1.1: Unit 5 Lab Assignment LabProgram.java 1 import java.util.*; 2 3 public class LabProgram { public static void main(String[] args) { /* Type your code below this line. Create additional lines as needed. */ 4 5 6 7 8 } // do not delete this line 9 // do not delete this line 10 0/7 Load default template...
Expert Answer:
Related Book For
Practicing Statistics Guided Investigations For The Second Course
ISBN: 9780321586018
1st Edition
Authors: Shonda Kuiper, Jeff Sklar
Posted Date:
Students also viewed these programming questions
-
One common way to test for authenticity of data is to analyze the frequencies of digits. When people are weighed and their weights are rounded to the nearest pound, we expect the last digits 0, 1, 2,...
-
x Current Attempt in Progress Your answer is partially correct. Kingbird Company's income statement for the year ended December 31, 2025, contained the following condensed information. Service...
-
Godwin Co. owns three delivery trucks. Details for each truck at the end of the most recent year follow: At the beginning of the year, a hydraulic lift is added to Truck 1 at a cost of $4,500. The...
-
Children out of School in America is a report on delinquency of school-age children prepared by the Childrens Defense Fund (CDF), a government-sponsored organization. Consider the following three...
-
A project costing $100 will produce perpetual net cash flows that have an annual volatility of 35% with no expected growth. If the project existed, net cash flows today would be $8. The project beta...
-
A college hockey coach collected data I from the 2010-2011 National Hockey League season. He hopes to convince his players that the number of shots taken has an effect on the number of goals scored....
-
The cash book contains which of the following accounts? a. Petty cash and Bank b. Drawings and Bank c. Bank and Cash d. Capital and Cash
-
It takes a force of 80.0N to compress the spring of a toy popgun 0.200m to load a 0.180-kg ball. With what speed will the ball leave the gun?
-
K Solve the equation. 4(x+1)-3=4(x-5)
-
1. At December 31, Hull Corp. had the following debt securities that were purchased during the year, its first year of operations: Cost Fair value Unrealized gain (loss) In Current Assets:...
-
Describe and explain the main categories of life insurance and general insurance.
-
Why are certain individual investment bank employees crucial to the banks profitability?
-
Describe the difference in the mix of assets in an investment portfolio held by (a) life insurance companies, (b) general insurance companies.
-
Explain what is meant by population standard deviation. Why is the size of the standard deviation in a given population important for variables sampling ?
-
Distinguish between the two main types of insurance.
-
Assume that you want to set up a restaurant of your own. (a) Differentiate between primary stakeholders and secondary stakeholders. (b) Explain and provide four (4) examples of primary stakeholders...
-
The nitrogen atoms in N2 participate in multiple bonding, whereas those in hydrazine, N2H4, do not. (a) Draw Lewis structures for both molecules. (b) What is the hybridization of the nitrogen atoms...
-
Which of the following is NOT a requirement in management's report on the effectiveness of internal controls over financial reporting? a. A statement of management's responsibility for establishing...
-
Which of the following is NOT an implication of Section 302 of the Sarbanes-Oxley Act? a. Auditors must determine, whether changes in internal control has, or is likely to, materially affect internal...
-
Which of the following is NOT a potential threat to computer hardware and peripherals? a. low humidity b. high humidity c. carbon dioxide fire extinguishers d. water sprinkler fire extinguishers
Study smarter with the SolutionInn App