| 1. |
Define a class RESORT with the following description in C++ : |
|
Answer» Private members: 1. Rno // Data member to store room number. 2. Name // Data member to store user name. 3. Charges // Data member to store per day charge. 4. Days //Data member to store the number of days. 5. Compute () // A function to calculate total amount as Days * Charges and if the //total amount exceeds 11000 then total amount is 1.02 * Days ’’’Charges. Public member: getinfo() // Function to Read the information like name, room no, charges and days dispinfo () // Function to display all entered details and total amount calculated //using COMPUTE function //include //include //include Class RESORT { Private: int Rno; char name [20]; float charges; int days; float compute(); Public: void getinfoO; void dispinfo(); } void RESORT: : getinfo() { cout <<“Enter Registration number:”; cin>> Rno.; cout <<“\n Enter name:”; gets(name); cout << “\n Enter per day charges:”; cin >> charges; cout <<“\n Enter number of days:”; cin >> days; } void RESORT: : dispinfo() { cout << “\n1. Registration number:” << Rno << “\n2. Name:”; puts(name); cout << “\n3. charges per day:” << charges << “\n4. Number of days:” <<days; cout<< “\n5. Amount:” << compute(); } long float; amount = charges*days; if (amount> 11000) amount = 1,02*days*charges; return amount; } RESORT obj; void main() { clrscr(); obj.getinfo(); obj.dispinfoQ; getch(); } |
|