Question: ***Java Code please*** In this assignment, you are asked to write a Java class (MyNumbersClass) that calculates the average of real numbers (double) using the

***Java Code please***

In this assignment, you are asked to write a Java class (MyNumbersClass) that calculates the average of real numbers (double) using the ArrayList. The numbers are separated by a white space and are stored in a .dat file. Refer to the UML design below.

Specifications:

1- The field filename stores the file that contains the numbers.

2- The default constructor sets the file name to a default String (input.dat) and creates the ArrayList object field with a capacity of 100.

3- The second constructor assigns the value of the argument to the filename field.

4- The ReadnumbersfromFile method reads the numbers from the file and stores them in the ArrayList object field.

5- The CalcAverage method iterates over all elements in the ArrayList object field and computes the average of the stored numbers. It returns the average value to the caller.

MyNumbersClass

- filename: String

- numbersList:ArrayList

+ MyNumbersClass()

+ MyNumbersClass(filename : String)

+ ReadnumbersfromFile() : void

+ CalcAverage() : double

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!