0

I was doing well in this project until I was trying to do the math problem on the third class.

The project is, we are supposed to create a base class of circle and create 2 derived classes

The first is sector derived from circle then the segment is derived from sector. It ran ok until the math in the sector was outputing junk. Can you show me why the values from circle and segment is not getting transferred despite calling it? NEED THE CODE ...

here it is!

```
#ifndef H_SECTOR
#define H_SECTOR
#include <iostream>
#include<cmath>
const double PI = 3.14;
using namespace std;
class Circle
{
public:
double Area;
Circle(); //default constructor
double getRadius(); // gets radius in radians
double calculateArea(); //calculates the area of circle
void show(); //display value
protected:
double Radius; // variable that stores radius
};
class Sector
{
protected:
double Angle;
public:
Sector(double Radius = 1.0): Circle(Radius){} //default constructor
double getAngle();
double calculateSector();
void show();
};
#endif
#include<iostream>
#include "Circle.h"
#include <cmath>
int main()
{
double Radius, Area;
double Angle, Sector;
Circle evaluateCircle;
Radius = evaluateCircle.getRadius();
Area = evaluateCircle.calculateArea();
evaluateCircle.show();
Sector evaluateSector;
Angle = evaluateSector.getAngle();
Sector = evaluateSector.calculateSector();
evaluateSector.show();
return 0;
}
Circle::Circle()
{ double Radius = 0;
}
double Circle::getRadius()
{
cout << "Enter the radius in radians ";
cin >> Radius;
return Radius;
}
double Circle::calculateArea()
{
Area = PI * pow(Radius, 2);
return Area;
}
void Circle::show()
{
cout << "The area of the circle is " << Area << endl;
}
Sector::Sector()
{
double Angle = 0;
double Radius = 0;
}
double Sector::getAngle()
{
cout << "Enter the angle in radians ";
cin >> Angle;
return Angle;
}
double Sector::calculateSector()
{
Sector = (pow(Radius,2)* PI * Angle)/ 360;
return Sector;
}
void Sector::show()
{
cout << "The sector is " << Sector << endl;
}
```