We help IT Professionals succeed at work.

Circle class

deep patel
deep patel asked
on
193 Views
Last Modified: 2017-04-04
i did my program but i m getting many error  in my program. errors like unexpected token ":" or ";" before double and this is my program.

 
#include<iostream>


 using namespace std;

 class Circle
 {
    private
    double PI = 3.14159;
    double radius;

    public Circle()
    {
        radius = 0.0;
    }

    public Circle(double r)
    {
        radius = r;
    }

    public void setRadius(double r)
    {
        radius = r;
    }

    public double getRadius()
    {
        return radius;
    }

    public double getArea()
    {
        return PI * radius * radius;
    }

    public double getDiameter()
    {
        return radius * 2;
    }

    public double getCircumference()
    {
        return 2 * PI * radius;
    }
 };


int main()
 {
     double radius;

     cout << "Enter the circle's radius:" << endl;
     cin >> radius;

     cout << "Radius:" << c.getRadius() << endl;

     cout << "Area:" << c.getArea() << endl;

     cout << "Diameter:" << c.getDiameter() << endl;

     cout << "Circumference:" << c.getCircumference() << endl;

     return 0;
 }

Open in new window

Comment
Watch Question

Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions