Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion
Computer Science
classes !!!!!!!!!
None
hey every1 do try this out!!!
for those who have C.S book,pg 227,Qno:4
f
or those who dont:
Q:a ticket booth sells tickets at Rs2.50/- per ticket.the booth requests the people entering the fare to buy one and keeps track of the no. of people passing.write a class with data members:no. of people and amt collected.
functions to:
1)increment people alone if ticket is not sold out.
2)increment both people and amt if ticket is sold out.
3)display these 2 amts
4)diplay no. of tickets sold out.
write each func in each post for convenience
rates assured
plz reply soon
!!!!!!!!!!!!!!!!!!!
Comments (2)
aparna ravi
Cool goIITian

Joined: 22 Mar 2007
Posts: 63
25 Mar 2008 22:44:09 IST
Like
2 people liked this
hi varsha!!!!!! heres d ans,,
#include<iostream.h>
#include<conio.h>
class Ticbooth
{
int no_people;
float amount;
public:
void initial();
void notsold();
void sold();
void disp_totals();
void disp_ticket();
};
void Ticbooth::initial()
{
no_people=0;
amount=0.0;
}
void Ticbooth::notsold()
{
no_people++;
}
void Ticbooth::sold()
{
no_people++;
amount+=2.50;
}
void Ticbooth::disp_total()
{
cout<<no_people<<"people visited"<<"\n";
void Ticbooth::disp_tickets()
{
int ticket=int(amount/2.50);
cout<<ticket<<"tickets sold"<<"\n";
}
void main()
{
clrscr();
Ticbooth stall1;
stall1.initial();
int ch();
do{
cout<<"choose one option";
cout<<"1.visitor has only signed the visitor book";
cout<<"2.visitor has purchased tickets also";
cout<<"3.exit";
cout<<"enter u r choice";
cin>>ch;
switch(ch)
{
case 1:stall1.notsold();
break;
case2:stall1.sold();
break;
case3:break;
default:cout<<"wrong choice";
};
}while(ch!=3);
stall1.disp_total();
stall1.disp_tickets();
}
hope this helps!!!!!!
Reply











