CPP program to create a class tourist and calculate the charges of touring

Source Code:
#include<iostream>
#include<string.h>
using namespace std;
class Tourist
{
int CNo;
char CType[40];
int Perkm;
int Distance;
public:
Tourist()
{
CType[40] ='A';
strcpy(CType,"0000");
}
void Citycharges()
{
if(CType[40]=='A')
Perkm=20;
if(CType[40]=='B')
Perkm=18;
if(CType[40]=='C')
Perkm=15;
}

void RegisterCab()
{
cout<<"Enter the cab.no: ";
cin>>CNo;
cout<<"Enter the cab type: ";
cin>>CType;
Citycharges();
}

void Display()
{
cout<<"Enter the Distance: ";
cin>>Distance;
cout<<"The cab no is: ";
cout<<CNo;
cout<<endl;
cout<<"Cab type is: "<<CType<<endl;
cout<<"Perkm charges are: "<<Perkm<<endl;
cout<<"The amount is: "<<Perkm*Distance<<endl;
}
};

int main()
{
Tourist T;
T.RegisterCab();
T.Display();
return 0;
}


Program Output :

Post a Comment

0 Comments