Hi,

I was wondering is there a way where you can sell limited tickets. For example there are 55 seats in a bus and 55 people bought the tickets for the bus,the people who want to buy those tickets for the bus must wait for an hour. How would I implement this code in Dev c++ . Thank you.

Why would they need to wait for an hour?
I must be missing something in the explanation.

Are you having problems with timing in the code or ticket sales or not showing the menu for an hour or ???

Thanks for the reply.The bus starts at 9am and every next bus comes in an hour and at 5pm the bus stop closes. So, I would just like to know how I can start it off.

I figured out how I can sell limited tickets, but if the tickets are sold out then they must wait for an hour, how would I do this? Thanks

That depends on how it will recognize the no-longer-sold-out condition.
If you really mean it should wait for an hour, you will need to:
0) Detect the sold-out condition
0a) Tell the user the tickets are sold out.
1) get the system time
2) if not previously in a sold-out condition: add an hour to that in some "other" variable
3) wait for the next request
3a) see if the system time is greater than or equal to the "other" variable
3b) if so, check to see if tickets are available
3c) if not, jump to step 1 (in this sequence)
4) Sell the user a ticket.

Now, the problem comes in when you detect the sold-out condition.
What are you checking to determine tickets are currently available?
If there is no proper check, you wil be stuck in a time loop of 1 hour every time a request comes in.

Is that what you mean?

Yes, that's what I meant thank you. The code below takes the quantity of tickets from the 55 tickets that is available and it stores the value in a text file. What I want the program to do is to store the amount of tickets that is available and then each time the program executes it will take away from the remaining tickets that is available. Thanks

int AmountOfTickets = 55; 

NewAmountOfTickets = AmountOfTickets - AdditonalAdultQty - AdditonalChildQty - AdditonalSeniorQty - AdditonalFamilyQty - AdultQty - ChildQty - SeniorQty - FamilyQty;   
     
         ofstream myfile1;
 
         myfile1.open ("Tickets Left.txt");
 
         myfile1 << NewAmountOfTickets;
 
         myfile1.close();
        
         NewAmountOfTickets1 = NewAmountOfTickets - AmountOfTickets - AdditonalAdultQty - AdditonalChildQty - AdditonalSeniorQty - AdditonalFamilyQty - AdultQty - ChildQty - SeniorQty - FamilyQty;
        
         ifstream inFile("Tickets Left.txt");
 
         inFile>> NewAmountOfTickets;
 
         inFile.close();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.