Answered step by step
Verified Expert Solution
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 COSC
ICE
In this ICE you will practice writing errorhandling 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 trycatch blocks to handle the following exceptions:
If the user inputs a nonnumeric 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 reprompt the user to enter a smaller value.
Example:
How many values do you want to enter:
Enter value #:
Enter value #: abc
Please enter a numeric value:
Enter value #:
Please enter a positive value:
Enter value #:
Please enter a smaller value:
The average is:
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 zipup 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 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 SergioSantilli@durhamcollege.ca as a contributor
on your project so I can obtain access to review.
Late submission result in a mark of zero
Good Luck!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started