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

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!

First of call, use code tags please...

code=c++

/code

...put your code between both statements but add brackets to them.

Secondly I tried checking your program - guess what, it doesn't compile. There are quite a few issues.

The first was the fact that you were calling the super constructor that didn't exist. I changed that, then ran into other problems in main, as well as the fact that your class didn't overload the std::ostream operator.

There were just too many problems, as well as a missing header file. You'll have to supply all of the code (or an ample amount of it) for us to steer you in the right direction to solving the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.