Question: This is a basic C++ question using dynamic array. Please fix my code Q. Create a dynamic array using the Circle class. The size of

This is a basic C++ question using dynamic array. Please fix my code

Q. Create a dynamic array using the Circle class. The size of the dynamic array is input by the user. The radius of the circle is set to be a random number between 1 and 100. Write a program to record the number of circles that are stored in a dynamic array that exceeds 100. Delete the dynamic array after use.

The result should be:

===================================================

Number of Circle: 3

Circle 1 radius >> 10

Circle 2 radius >> 20

Circle 3 radius >>30

3 circles are larger than area of 100

===========================================

This is the code I made so far... please fix

#include

#include

using namespace std;

class Circle

{

public:

void setRadius(int radius);

double getArea();

private:

int radius;

};

void Circle::setRadius(int radius)

{

radius = rand();

radius = radius;

}

double Circle::getArea()

{

double area = 3.14* 3.14 *radius;

return area;

}

int main()

{

Circle c;

int num;

cout << "Number of circle makes : ";

cin >> num;

int *ptr = new int[num];

for (int i = 0; i < num; i++)

{

cout << "Circle " << i + 1 << "radius: >>";

cin >> ;

}

cout <<"Number of Circles larger than 100 "<<

}

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!