Ans:
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iostream.h>
class Tour
{
char TCode[21];
int NoofAdults,NoofKids,Kilometres;
float TotalFare;
public: Tour( ) strcpy(TCode,"NULL");
{
NoofAdults=NoofKids=Kilometres=TotalFare=0;
}
void AssignFare( )
if(Kilometres>=1000)
{
TotalFare=NoofAdults*500+NoofKids*250;
else if(Kilometres>=500) TotalFare=NoofAdults*300+NoofKids*150;
else TotalFare=NoofAdults*200+NoofKids*100;
}
void EnterTour( )
cout<<"\nEnter the Tour Code: ";
{
gets(TCode);
cout<<"\nEnter the Number of Adults: ";
cin>>NoofAdults;
cout<<"\nEnter the Number of Kids: ";
cin>>NoofKids;
cout<<"\nEnter the Number of Kilometres: ";
cin>>Kilometres; AssignFare( );
}
void ShowTour( )
{
cout<<"\nThe Tour Code: "<<TCode;
cout<<"\nThe Number of Adults: "<<NoofAdults;
cout<<"\nThe Number of Kids: "<<NoofKids;
cout<<"\nThe Number of Kilometres: "<<Kilometres;
cout<<"\n\nThe Total Fare: "<<TotalFare;
}
};
void main( )
{
clrscr();
Tour T;
T.EnterTour( );
T.ShowTour( );
getch();
}