1. Engineering
  2. Computer Science
  3. write a simple driverclientmain class with 2 methods the main...

Question: write a simple driverclientmain class with 2 methods the main...

Question details

Write a simple driver/client/main class with 2 methods. The main() method should:

  • Call a method called fileAverage()
  • If the method generates an exception, print out the message generated by the Exception

The fileAverage() 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 InsufficientDataException with the message "Exception: Not enough data in the file!"
  • Calculate the average (mean) of the numbers in your array or ArrayList (must have a separate loop that goes through the array or ArrayList to sum 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 average is greater than 100, print "The average is large"
    • If the average is less than 100, print "The average is small"
    • If the average is exactly 100, print "The average is exactly 100"
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution