/* Define a class Hotel with following description private members RNo. of int, name of string, tariff(float), nod (number of days) of int. Cal() function to calculate and return amount as number of days.
if the value of nod*tariff > 1000 then amount= 1.05* nod *tariff.
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class hotel
{
int rno ;
float amount;
char name[50];
float tarrif;
int nod;
void calc() ;
public:
void checkin();
void checkout();
};
void hotel::calc ()
{ if(nod*tarrif>=1000)
{amount=1.05*nod*tarrif;
cout << "\nThe amount is " ;
cout << amount ;
getch() ;
}
else
{
amount=nod*tarrif;
cout<<"\n amount is:";
cout << amount ;
getch() ;
}
}
void hotel::checkin()
{
cout<<"\n enter room no.";
cin>>rno;
cout<<"\n enter name :";
gets(name);
cout<<"enter tariff :";
cin>>tarrif;
cout<<"\n entet the no. of days:";
cin>>nod;
}
void hotel:: checkout()
{
cout<<"\nthe room no is"<<rno;
cout<<"\n the name is:";
puts(name);
cout<<"\n tariff is:"<<tarrif;
cout<<"\n no. of days is:"<<nod;
calc();
}
void main ()
{
clrscr ();
hotel x ;
x.checkin();
x.checkout();
}
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class hotel
{
int rno ;
float amount;
char name[50];
float tarrif;
int nod;
void calc() ;
public:
void checkin();
void checkout();
};
void hotel::calc ()
{ if(nod*tarrif>=1000)
{amount=1.05*nod*tarrif;
cout << "\nThe amount is " ;
cout << amount ;
getch() ;
}
else
{
amount=nod*tarrif;
cout<<"\n amount is:";
cout << amount ;
getch() ;
}
}
void hotel::checkin()
{
cout<<"\n enter room no.";
cin>>rno;
cout<<"\n enter name :";
gets(name);
cout<<"enter tariff :";
cin>>tarrif;
cout<<"\n entet the no. of days:";
cin>>nod;
}
void hotel:: checkout()
{
cout<<"\nthe room no is"<<rno;
cout<<"\n the name is:";
puts(name);
cout<<"\n tariff is:"<<tarrif;
cout<<"\n no. of days is:"<<nod;
calc();
}
void main ()
{
clrscr ();
hotel x ;
x.checkin();
x.checkout();
}
No comments:
Post a Comment