Define a class RESORT in C++ with following description:
Private Members:
- Rno // Data Member to store Room No.
- Name // Data Member to store Customer Name
- Charges // Data Member to store per day charges
- Days // Data Member to store number of days of stay
- COMPUTE()// Member function to calculate and retun Amount
// If the Charges*Days amount is more than 11000
// then it should return 2% extra on it.
Public Members
-GetInfo() // A function to enter the content of Rno, Name, Charges & days.
-DispInfo() // A function to display details also calls the COMPUTE() function.
==================================================================
Solution
==================================================================
class RESORT
{
int Rno;
char Name[20];
float charges;
int Days;
float COMPUTE();
public:
void GetInfo();
void DispInfo();
};
void RESORT::GetInfo()
{
cout<<"Enter Room No. : ";
cin>>Rno;
cout<<"Enter Name : ";
gets(Name);
cout<<"Enter Charges : ";
cin>>charges;
cout<<"Enter Days to stay: ";
cin>>Days;
}
float RESORT::COMPUTE()
{
if(Days*charges>11000)
return(1.02*Days*charges);
else
return (Days*charges);
}
void RESORT::DispInfo()
{
cout<<"............Customer Details............\n";
cout<<"========================================\n";
cout<<"Room No. : "<<Rno<<endl;
cout<<"Name : "<<Name<<endl;
cout<<"Room Charges : "<<charges<<endl;
cout<<"Days Stayed : "<<Days<<endl;
cout<<"Total Amount : "<<COMPUTE()<<endl;
}
- Rno // Data Member to store Room No.
- Name // Data Member to store Customer Name
- Charges // Data Member to store per day charges
- Days // Data Member to store number of days of stay
- COMPUTE()// Member function to calculate and retun Amount
// If the Charges*Days amount is more than 11000
// then it should return 2% extra on it.
Public Members
-GetInfo() // A function to enter the content of Rno, Name, Charges & days.
-DispInfo() // A function to display details also calls the COMPUTE() function.
==================================================================
Solution
==================================================================
class RESORT
{
int Rno;
char Name[20];
float charges;
int Days;
float COMPUTE();
public:
void GetInfo();
void DispInfo();
};
void RESORT::GetInfo()
{
cout<<"Enter Room No. : ";
cin>>Rno;
cout<<"Enter Name : ";
gets(Name);
cout<<"Enter Charges : ";
cin>>charges;
cout<<"Enter Days to stay: ";
cin>>Days;
}
float RESORT::COMPUTE()
{
if(Days*charges>11000)
return(1.02*Days*charges);
else
return (Days*charges);
}
void RESORT::DispInfo()
{
cout<<"............Customer Details............\n";
cout<<"========================================\n";
cout<<"Room No. : "<<Rno<<endl;
cout<<"Name : "<<Name<<endl;
cout<<"Room Charges : "<<charges<<endl;
cout<<"Days Stayed : "<<Days<<endl;
cout<<"Total Amount : "<<COMPUTE()<<endl;
}
No comments
Post your comments