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