Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

How does the Sarbanes-Oxley Act relate to internal controls?

Answered: 1 week ago