Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!