Design a class that has an array of floating-point numbers.The constructor shoul
ID: 3619322 • Letter: D
Question
Design a class that has an array of floating-point numbers.The constructor should accept an integer argument and dynamicallyallocate the array to hold that many numbers. The destructor shouldfree the memory held by the array. In addition, there should bemember functions to perform the following operations: *Store a number in any element of the array *Retrieve a number from any element of the array *Return the highest value stored in the array *Return the lowest value stored in the array *Return the average of all the numbers stored in thearray Demonstrate the class in a program. Design a class that has an array of floating-point numbers.The constructor should accept an integer argument and dynamicallyallocate the array to hold that many numbers. The destructor shouldfree the memory held by the array. In addition, there should bemember functions to perform the following operations: *Store a number in any element of the array *Retrieve a number from any element of the array *Return the highest value stored in the array *Return the lowest value stored in the array *Return the average of all the numbers stored in thearray Demonstrate the class in a program.Explanation / Answer
please rate - thanks #include using namespace std; class array { private: double *ptr; int size; public: array(int i) {ptr=new double[i]; size=i; } ~array() {delete ptr; } void setnum(int i, double n) { *(ptr+i)=n; } double getnum(int i) {return *(ptr+i); } double average() {double sum=0; int i; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.