Write the definition of a class RING in C++ with the following description:
Private Members
- RingNumber // data member of integer type
- Radius // data member of float type
- Area // data member of float type
- CalcArea() // Member function to calculate and assign
// Area as 3.14 * Radius*Radius
Public Members
- GetArea() // A function to allow user to enter values of
// RingNumber and Radius. Also, this
// function should call CalcArea() to calculate
// Area
- ShowArea() // A function to display RingNumber, Radius
// and Area
class RING
{
int RingNumber;
float Radius;
float Area;
void CalcArea(){Area=3.14*Radius*Radius;
}
public:
void GetArea();
void ShowArea();
};
void RING::GetArea()
{
cin>>RingNumber>>Radius;
CalcArea();
}
void RING::ShowArea()
{
cout<<RingNumber<<' '<<Radius<<' '<<Area<<endl;
}