#include <iostream.h>
class Tollboth //class declaretion
{
//attributes
int cars;
double collect;
public:
//contstructor
Tollboth()
{
cars=0;
collect=0;
}
//methods
void payingcar() //paying car method
{
cars++;
collect+=50;
cout<<"Entry Succesfully added."<<endl;
}
void nopayingcar() //nonpaying car method
{
cars++;
cout<<"Entry Succesfully added."<<endl;
}
void display() //methods to display
{
cout<<"Total numbers of cars: "<<cars<<endl;
cout<<"Total payment: "<<collect<<endl;
}
};
main()
{
int ask;
char ag;
Tollboth a; // create objects
again: //lable
cout<<"Press 1 if payment is delievered by car owner.\n";
cout<<"Press 2 if payment is not delievered by car owner.\nPress 3 to display total payment and cars.\nPress 1 or 2 or 3: "<<endl;
//ask paying cara or nonpaying car.
cin>>ask;
if(ask==1)
{
a.payingcar();
}
else if(ask==2)
{
a.nopayingcar();
}
else if(ask==3)
{
a.display();
}
else
{
cout<<"Enter Valid Data."<<endl;
goto again;
}
//ask to calculation again.
cout<<"You like to enter data again? Y/N ";
cin>>ag;
if(ag=='Y' || ag=='y')
{
goto again; //goto lable again at above.
}
}
class Tollboth //class declaretion
{
//attributes
int cars;
double collect;
public:
//contstructor
Tollboth()
{
cars=0;
collect=0;
}
//methods
void payingcar() //paying car method
{
cars++;
collect+=50;
cout<<"Entry Succesfully added."<<endl;
}
void nopayingcar() //nonpaying car method
{
cars++;
cout<<"Entry Succesfully added."<<endl;
}
void display() //methods to display
{
cout<<"Total numbers of cars: "<<cars<<endl;
cout<<"Total payment: "<<collect<<endl;
}
};
main()
{
int ask;
char ag;
Tollboth a; // create objects
again: //lable
cout<<"Press 1 if payment is delievered by car owner.\n";
cout<<"Press 2 if payment is not delievered by car owner.\nPress 3 to display total payment and cars.\nPress 1 or 2 or 3: "<<endl;
//ask paying cara or nonpaying car.
cin>>ask;
if(ask==1)
{
a.payingcar();
}
else if(ask==2)
{
a.nopayingcar();
}
else if(ask==3)
{
a.display();
}
else
{
cout<<"Enter Valid Data."<<endl;
goto again;
}
//ask to calculation again.
cout<<"You like to enter data again? Y/N ";
cin>>ag;
if(ag=='Y' || ag=='y')
{
goto again; //goto lable again at above.
}
}