Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a simple driver/client/main class with 2 methods. On java. The main() method should: Call a method called fileMax() If the method generates an exception,
Write a simple driver/client/main class with 2 methods. On java.
The main() method should:
- Call a method called fileMax()
- If the method generates an exception, print out the message generated by the Exception
The fileMax() method should:
- Read in the data from a file called: numbers.txt The numbers from the file should be stored into your choice of an array or ArrayList... A sample version of this file has been provided, but the one being tested with may have between 1 and 10000 numbers.
- If the array or ArrayList contains only 1 element (because the file only contained one element), throw an MissingDataException with the message "Exception: File doesn't have enough data!"
- Calculate the maximum of the numbers in your array or ArrayList (must have a separate loop that goes through the array or ArrayList to find the maximum of the values in the array or ArrayList to receive full credit)
- Print the average calculated by the code along with the EXACT correct message from below:
- If the maximum is greater than 100, print "There is a big number in the file"
- If the maximum is less than 100, print "The numbers in the file are small"
- If the maximum is exactly 100, print "The maximum is exactly 100"
Grading Breakdown:
- 10 -- Correctly and completely reading from the file and storing it into your array or ArrayList
- 5 -- Correctly and completely using a loop to calculate the maximum of the numbers in your array or ArrayList
- 5 -- Correctly and completely providing the required output of the program
- 10 -- Correctly creating the Exception class
- 10 -- Correctly generating/throwing the Exception
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