1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svet-max [94.6K]
3 years ago
7

Design a class that has an array of floating-point numbers. The constructor should accept an integer argument and dynamically al

locate the array to hold that many numbers. The destructor should free the memory held by the array. In addition, there should be member 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 the array Demonstrate the class in a main program. All methods should be implemented and called.
Computers and Technology
1 answer:
attashe74 [19]3 years ago
6 0

Answer:

See explaination for the code

Explanation:

Here is the code

class NumberArray

{

private:

float *aptr; // Pointer to the array

int arraySize; // Holds the array size

float max,min,avg;

public:

NumberArray(int); // Constructor

~NumberArray(); // Destructor

int size() const // Returns the array size

{ return arraySize; }

void storeNumber(float num,int ele);

float retrieveNumber(int ele);

float getHighest();

float getLowest();

float getAverage();

};

//*******************************************************

// Constructor for IntArray class. Sets the size of the *

// array and allocates memory for it. *

//*******************************************************

NumberArray::NumberArray(int s)

{

arraySize = s;

aptr = new float [s];

for (int count = 0; count < arraySize; count++)

*(aptr + count) = 0;

}

//******************************************************

// Destructor for IntArray class. *

//******************************************************

NumberArray::~NumberArray()

{

if (arraySize > 0)

delete [] aptr;

}

void NumberArray::storeNumber(float num,int ele)

{

if(ele<arraySize)

*(aptr+ele)=num;

}

float NumberArray::retrieveNumber(int ele)

{

return *(aptr+ele);

}

float NumberArray::getHighest()

{

float high=*(aptr+0);

for(int i=1;i<arraySize;i++)

if(high<*(aptr+i))

high=*(aptr+i);

return high;

}

float NumberArray::getLowest()

{

float low=*(aptr+0);

for(int i=1;i<arraySize;i++)

if(low>*(aptr+i))

low=*(aptr+i);

return low;

}

float NumberArray:: getAverage()

{

float ag=0;

for(int i=1;i<arraySize;i++)

ag+=*(aptr+i);

ag=ag/arraySize;

return ag;

}

//Header file section

#include <iostream>

using namespace std;

int main()

{

const int SIZE = 10; // Array size

// Define an IntArray with 10 elements.

NumberArray table(SIZE);

//function call to store values

table.storeNumber(1,0);

table.storeNumber(3,1);

table.storeNumber(7,2);

table.storeNumber(2,3);

//display values

cout<<"Highest value:"<<table.getHighest()<<endl;

cout<<"Lowest Value:"<<table.getLowest()<<endl;

cout<<"Average:"<<table.getAverage()<<endl;

///pause system for a while

system("pause");

return 0;

}

You might be interested in
Part 2: Code the Program
OverLord2011 [107]

Answer:

# Name - Today's Date

# Description

def main():

    print("My favorite TV show is Mythbusters.")

    print("I like it because I learn a lot and they do crazy experiments.")

main()

(this is the best I can do since it's a specific result based on the choices you make, but I did the example code and you just need to fill it in with the necessary requirements. I also tested it on IDLE. )

8 0
3 years ago
Which type of drawer has three dispensing modes: single-dose, multi-dose, and matrix?
ad-work [718]

Answer:

CUBIE MiniDrawer Bin

Explanation:

MiniDrawers comes in two configurations, and each fitting comes in one drawerslot. The MiniDrawer (1-6) comes with the most primary pocket dimensions. And we have the 18-tray MiniDrawer (1-8) comes with another dimensions in its basic form. You will in fact find various pocket dimensions like 1,2,3,4,6,12, and these comes within the 18-tray and 6-tray MiniDrawers. And they come in all the dispensing modes mentioned in the question. Hence, the above answer. The answer is clear from the options as well, and since it has the matrix mode as well apart from single dose mode and multi dose mode.

6 0
3 years ago
How is it possible for the router to know whether it is supposed to send a cat photo to your laptop
kupik [55]

It is possible for the router to know whether it is supposed to send a cat photo to your laptop because  It uses the private IP address.

Router  is a  device that help to transfer data and across the internet or across the user device and the internet.

Private IP addresses are internet protocol addresses that is often  assign to user device by   router in order to a successful communicate to take place between the internet and user device.

Private IP addresses are mostly at:

•Home

•Office

•Business  environments

Inconclusion It is possible for the router to know whether it is supposed to send a cat photo to your laptop because  It uses the private IP address.

Learn more here:

brainly.com/question/19112414

3 0
2 years ago
Identify the primary responsibilities associated with each of the following web design roles: content writer/editor, artist/grap
frosja888 [35]

A web designer/developer is responsible for the design, layout and coding of a website. They are involved with the technical and graphical aspects of a website and how the site works and how it looks.

Explanation:

  • A content writer/editor creates and revises the text that visitors read when the visit a website, choose a link, image, video, or other media that enhances your text content.
  • A web artists/graphic designer's responsibility is to create original art, such as logos, stylized typefaces, and avatars, and props for virtual 3-d worlds.
  • A web designer's role is to create webpages that combine, text, images, and links using tools such as markup languages; CCS, HTML, and WYSIWYG editors.
  • Web programmer/database developer's job is to script languages such as, JavaScript, ASP, PHP, and MYSQL and must plan, create, secure, and maintain databases of varying complexity.
  • Web Administrator assumes all roles, including creative, high-tech, and oversight. May oversee a web development team that includes technical and creative roles.
5 0
3 years ago
What refrigerant has been approved for new household refrigerators and freezers
Alexxx [7]
Bsbsnsnsnsn jajwjemoeododhdhdw whajsjshtzzvsssnxbba. 3
8 0
3 years ago
Other questions:
  • Help plz
    5·1 answer
  • The __________ is a visual or textual storyboard that will assist in determining the type of web pages on your site.
    14·1 answer
  • Almost immediately after a server migration project, employees are complaining that they can't reach the Internet. You sit down
    8·1 answer
  • How can software be used to protect against hardware failures in systems that embody both? Give two examples of how software can
    14·1 answer
  • Wireless data networks are particularly susceptible to known ciphertext attacks.
    10·1 answer
  • Design a class called NumDays. The class’s purpose is to store a value that represents a number of work hours and convert it to
    12·1 answer
  • How to create a network of relevant prospects?
    5·1 answer
  • The create_python_script function creates a new python script in the current working directory, adds the line of comments to it
    6·1 answer
  • What relationship do MP3s and MP3 players have with video files?
    11·1 answer
  • Which type of evidence should victims collect to help officials catch cyber bullies?home addressesbirthdayssocial media username
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!