Question
10. Number Array Class Design a class that has an array of floating-point numbers. The constructor should accept an integer argument and dynamically allocate the
10. NumberArrayClass
Design aclassthat has anarrayof floating-point numbers. Theconstructorshould accept aninteger
argumentand dynamically allocate thearrayto hold that many numbers. Theprivatedata members of
theclassshould include theintegerargumentin avariableto hold the size of thearrayand a
pointer to floattypeto hold the address of the firstelementin thearray.
The destructor should free the memory held by thearray.
In addition, there should be member functions to perform the followingoperations:
Storea number in anyelementof thearray
Retrieve a number from anyelementof thearray
Return the highestvaluestoredin thearray
Return the lowestvaluestoredin thearray
Return the average of all the numbersstoredin thearray
Demonstrate theClassin aProgram
SAMPLE RUN #0:./Dynamic-Number-Class-Array
Interactive Session
Standard Error (empty)
Standard Output
Hide Invisibles
Highlight:
None
Standard Input Only
Prompts Only
Standard Output w/o Prompts
Full Standard Output
All
Show Highlighted Only
CreatingaFloatClassArrayObjectwithasizeof5.UsingsetIfunctionwithcalls(0,1.4),(1,2.3),(2,3.13),(3,6.66),(4,7.711)toloadarray. UsinggetIwithalllegitmateindexvaluestoprintarray. ThevalueoffArray1[0]=1.4 ThevalueoffArray1[1]=2.3 ThevalueoffArray1[2]=3.13 ThevalueoffArray1[3]=6.66 ThevalueoffArray1[4]=7.711 CallinggetHireturnshighestvalueinarrayas:7.711 CallinggetLowreturnslowestvalueinarrayas:1.4 CallinggetAvgreturnstheaverageofthearrayas:4.2402
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