FRIEND FUNCTION USING C++



/*HOTEL MANAGEMENT USING FRIEND FUNCTION*/

PROGRAM:

#include<iostream.h>
#include<conio.h>
class hotel
{
private:
 long int rmno,cpn,rent,days,amt;
 char name[20];
public:
 void booking();
 void display();
 friend void amount(int amt);
}h[10];
void hotel::booking()
{
 cout<<"\n Enter customer name:";
 cin>>name;
 cout<<"\n Enter customer phone no:";
 cin>>cpn;
 cout<<"\n Enter room no:";
 cin>>rmno;
 cout<<"\n Enter rent for days:";
 cin>>rent;
 cout<<"\n Enter no of days:";
 cin>>days;
}
void hotel::display()
{
 int temp;
 cout<<name<<"\t\t"<<cpn<<"\t\t"<<rmno<<"\t\t"<<rent<<"\t\t"<<days;
 temp=days*rent;
 amount(temp);
}
void amount(int amt)
{
 cout<<"\t"<<amt;
}
void main()
{
 int n,i;
 clrscr();
 cout<<"\n\t HOTEL MANAGEMENT USING FRIEND FUNCTION ";
 cout<<"\n\t ---------------------------------------------------------------------\n";
 cout<<"\n Enter the no of customer:";
 cin>>n;
 for(i=0;i<n;i++)
 h[i].booking();
 cout<<"\n\t CUSTOMER DETAILS";
 cout<<"\n  Customer Name \t Customer Phno \t Room No \t Rent Perday \t No Of Day \t Total Rent";
cout<<”\n  ____________________________________________________________________”;
 for(i=0;i<n;i++)
 h[i].display();
 getch();
}
 

OUTPUT:


         HOTEL MANAGEMENT USING FRIEND FUNCTION
         -------------------------------------------------------------

 Enter the no of customer:2

 Enter customer name:vivek

 Enter customer phone no:56789

 Enter room no:9

 Enter rent for days:500

 Enter no of days:5

 Enter customer name:vinoth

 Enter customer phone no:86544

 Enter room no:54

 Enter rent for days:1000

 Enter no of days:10

 CUSTOMER DETAILS

Customer Name  Customer Phno   Room No  Rent Perday  No Of Day     Total Rent

vivek                56789                    9               500                  5               2500                                   
vinoth               86544                   54             1000               10              10000



Comments

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE