Hello Friends !!!! Today I am going to tell about the simple program of Toolbooth. In this program we show the working of a toolbooth.Create a class of Toolbooth and show the working of Toolbooth using constructor in C++.
So here is Program=>
//Name : Mayank Sharma
//Roll No : 26
//C.S.E(4th Sem)
// Write a Program To Show the Working of Toolbooth //
#include
#include
const char ESC=27;
const double toll=0.5;
class tollbooth
{
int totalcars;
double totalcash;
public:
tollbooth() :totalcars(0),totalcash(0.0)
{}
void payingcar()
{
totalcars++;totalcash+=toll;
}
void nonpaycars()
{
totalcars++;
}
void display()
{
cout<<"\n cars="<
int main()
{
tollbooth b1;
char c;
clrscr();
cout<<"\n Press 0 for paying cars";
cout<<"\n Press 1 for nonpaying cars";
cout<<"\n Press ESC for exit"<
{
c=getche();
if(c=='0')
b1.payingcar();
if(c=='1')
b1.nonpaycars();
}while(c !=ESC);
b1.display();
getch();
return 0;
}
Output of program is :
Press 0 for paying cars
Press 1 for nonpaying cars
Press ESC for exit
00
cars=3
cash=1.5
I think this post will help you.I think this post will help you.
Thanks!!!
If any query about this post then put your comment in comment box below..






0 comments:
Post a Comment