Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Durham College COSC 1 2 0 0 1 ICE 3 In this ICE you will practice writing error - handling and follow guidelines discussed in

Durham College COSC1200
1
ICE3
In this ICE you will practice writing error-handling and follow guidelines discussed in class.
Write a Java program that calculates the average of numbers entered by the user. The program
will first prompt the user to enter the number of values they want to input, then prompt them to
enter each value. The program should then calculate the average of the input values and output
the result.
The program should also use try-catch blocks to handle the following exceptions:
- If the user inputs a non-numeric value, the program needs to output an error message and reprompt the user to enter a valid numeric value.
- If the user inputs a negative value, the program should output an error message and reprompt the user to enter a positive value.
- If the user inputs a value that is too large to be stored in an Integer, the program should
output an error message and re-prompt the user to enter a smaller value.
Example:
How many values do you want to enter: 4
Enter value #1: 10
Enter value #2: abc
Please enter a numeric value: 20
Enter value #3: -10
Please enter a positive value: 15
Enter value #4: 5000000000000000
Please enter a smaller value: 10000
The average is: 2511.25
2
General Requirements
Include an opening comment with your name, the name of the program, the date, and a
short description.
Follow the style guide! Use descriptive names and sensible datatypes for variables,
constants, arrays, functions, etc. that follow our naming conventions. Use good spacing
and make sure braces ({}) are located where they are supposed to be.
Output messages must be meaningful. Displaying values is not enough, the user must
understand what he is seeing.
Take screen shots of your code and its output. Put them in a pdf. The screenshots must be
clear. You can have the code and output in the same screenshot.
Screenshots
Your assignment submission must include:
- Screenshots of your source code AND Program execution must be submitted.
- All Screenshots must be in pdf format
- Do NOT zip-up your screenshots.
- Attach all screenshots separately
- Failure to comply with any of these Screenshots stipulations, can and will result in a mark
of ZERO
- An assignment submission will not be accepted without proper screenshot attachments.
Submission:
- You will be responsible for submitting your Git URL and your screenshots on DC
connect.
- A few things you must be aware of before submitting:
o Submissions are only accepted via DCConnect (not email) before due date
o Up to -25% deduction if you decide to submit a zip up or compress files
o Grades will be granted according to class coding guidelines, professionalism,
output clarity and solution ingenuity.
- A working link to your completed private project on GitHub
o Please make sure you add me (Sergio.Santilli@durhamcollege.ca) as a contributor
on your project so I can obtain access to review.
- Late submission result in a mark of zero (0%).
3
Good Luck!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

define the term outplacement

Answered: 1 week ago

Question

describe the services that an outplacement consultancy may provide.

Answered: 1 week ago