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
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