Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion



Computer Science

varsha valli g.'s Avatar
Blazing goIITian

Joined: 31 Jan 2007
Post: 515
25 Mar 2008 17:50:39 IST
0 People liked this
2
556 View Post
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
!!!!!!!!!!!!!!!!!!!


Share this article on:

Comments (2)

aparna ravi's Avatar

Cool goIITian

Joined: 22 Mar 2007
Posts: 63
25 Mar 2008 22:44:09 IST
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!!!!!!
 
 
varsha valli g.'s Avatar

Blazing goIITian

Joined: 31 Jan 2007
Posts: 515
26 Mar 2008 12:30:24 IST
0 people liked this

MY DOUBT IS HOW DO U DISPLAY THE 2 AMOUNTS ???????

!!!!!!!!!!!!!!



Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads