You are on page 1of 3

________________________________

Write a programme to define a class named resort with following


specifications:
Private members/functions : roll_no, customer name, charge per
day, stay time , a function compute to calculate the total cost of
stay
Public members/functions : a function to read the information
and a function to display information.
(special condition ,if the total cost is more than 11000 then total
cost is equal to (charge_per_day) * (days_of_stay)* 1.02 )


#include<iostream.h>
#include<conio.h>
#include<stdio.h>

class resort
{
int room_no;
char customer_nm[20];
float charge_per_day;
int days_of_stay;
float compute( float charge_per_day , int days_of_stay )
{
float total;
total= (charge_per_day) * (days_of_stay);
if(total>11000)
{ total= (charge_per_day) * (days_of_stay)*1.02; }
return total;
}

public:
void readinfo();
void displayinfo();

} customer1;



void resort::readinfo()
{

cout<<"Enter the room number:";
cin>>room_no;
cout<<"\nEnter the customer name:";
gets(customer_nm);
cout<<"\nEnter the room charges per day:";
cin>>charge_per_day;
cout<<"\nEnter the number of days of stay:";
cin>>days_of_stay;
}

void resort::displayinfo()
{
cout<<"\nRoom number is:"<<room_no;
cout<<"\nName of the customer is:"<<customer_nm;
cout<<"\nRoom charge per day is:"<<charge_per_day;
cout<<"\nStay(days):"<<days_of_stay;
cout<<"\nTotal
charges:"<<compute(charge_per_day,days_of_stay);
}


void main()
{
clrscr();
customer1.readinfo();
customer1.displayinfo();
getch();
}


Output:

Enter the room number: 241
Enter the customer name: Sonal Sharma
Enter the room charges per day: 500
Enter the number of days of stay: 4

Room number is: 241
Name of the customer is: Sonal Sharma
Room charges per day: 500
Stay (days): 4
Total charges: 2000

You might also like