my assgment-- animal show ticketing system

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2009
Posts: 14
Reputation: spoinkgeek is an unknown quantity at this point 
Solved Threads: 0
spoinkgeek spoinkgeek is offline Offline
Newbie Poster

my assgment-- animal show ticketing system

 
0
  #1
Aug 5th, 2009
hello
im doing this assgment.need a solution urgently! Animal Show is organized.
There are 2 sessions for the show, which are 2pm-4pm and 8pm-10pm per day.
There are only 50 tickets available per session per day.
For the show, a ticket for an adult sells for RM10 while for a child of below 12 years of age, the ticket sells for RM5.
When a customer buys a ticket, the cashier would key in the number of adults and number of children. The system would then calculate the total amount to be paid. The system would then print the details and total of the purchase on the screen.
If the total of tickets for a session has reached the capacity (50 tickets), the program would print a warning to the cashier. Your program should be able to print the total amount of sales at the end of the day as a sales report.

these are the things in the coding.The problem is how write the codes using all functions such as if else statements,switch and ext.. I'm new to C++. Can you please guide me a solution?? Currently,im using dev c++ platform. Thanks a lot. Eager to hear from your side. It will be useful in my studies.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 255
Reputation: Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough 
Solved Threads: 17
Hiroshe's Avatar
Hiroshe Hiroshe is offline Offline
Posting Whiz in Training

Re: my assgment-- animal show ticketing system

 
0
  #2
Aug 5th, 2009
>The problem is how write the codes using all functions such as if else statements,switch and ext..
You need to learn the basics befor you can do this problem.
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 12
Reputation: ryancfc is an unknown quantity at this point 
Solved Threads: 0
ryancfc ryancfc is offline Offline
Newbie Poster

Re: my assgment-- animal show ticketing system

 
0
  #3
Aug 5th, 2009
Yes, you need to learn the basics first, if you need a quick fix with a few hours to spare to learn. Go on Youtube and search 'thenewboston' and click on his channel and then on the playlist of C++ videos, pretty much straight to the point, with the basics of if functions, else if, structures, user input and output, functions. He is great but video tutorials cannot always explain anything so don't use this long term.

For long term put C++ Tutorial (1) - Absolute n00b spoonfeed into the search field, he isn't English but is brilliant for understanding extras and underlying sciences of it. He has 70 videos times ten mins.

Use thenewboston for quick fixes.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 14
Reputation: spoinkgeek is an unknown quantity at this point 
Solved Threads: 0
spoinkgeek spoinkgeek is offline Offline
Newbie Poster

Re: my assgment-- animal show ticketing system

 
0
  #4
Aug 6th, 2009
but,i got the basic.i already tried doing it.it failed! so,im not sure which proper way to write the codes. any example?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 14
Reputation: spoinkgeek is an unknown quantity at this point 
Solved Threads: 0
spoinkgeek spoinkgeek is offline Offline
Newbie Poster

Re: my assgment-- animal show ticketing system

 
0
  #5
Aug 6th, 2009
i do have basic. but,in a problem solving kind of assgm,im blur! i have started it,it doesnt display n has error.. this is my example... would u mind checking ?! thanks..

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int adults;
  6. int children;
  7. int total_amount;
  8.  
  9. cout<<"Press return after entering a number .\n";
  10. cout<<"Enter the number of adults :\n";
  11. cin>>adults;
  12.  
  13. cout<<"Enter the number of children :\n";
  14. cin>>children;
  15.  
  16. { if (adults + children > 50);
  17. "warning to cashier\n";
  18. total_amount = (adults * 10) + (children * 5)
  19. cout<<"There are seats available. \n";
  20.  
  21.  
  22. else
  23. total_amount = (adults * 10) + (children * 5)
  24. cout<<"It's full,please come again next time! \n";
  25. }
  26.  
  27. cout<<" Animal Show in Zoo Melaka says that ";
  28. cout<<adults;
  29. cout<<"number of adults \n";
  30. cout<< "and ";
  31. cout<<children;
  32. cout<<"number of children, then \n";
  33. cout<< "The total amount that you have to pay is RM ";
  34. cout<<total_amount;
  35.  
  36. system ("pause");
  37. return 0;
  38.  
  39. }
Last edited by John A; Aug 6th, 2009 at 9:25 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 255
Reputation: Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough 
Solved Threads: 17
Hiroshe's Avatar
Hiroshe Hiroshe is offline Offline
Posting Whiz in Training

Re: my assgment-- animal show ticketing system

 
0
  #6
Aug 6th, 2009
Put your code in code tags: [code=cplusplus]<code here> [/code]
Judging from your code:
  1. { if (adults + children > 50);
  2. "warning to cashier\n";
  3. total_amount = (adults * 10) + (children * 5)
  4. cout<<"There are seats available. \n";
  5.  
  6.  
  7. else
  8. total_amount = (adults * 10) + (children * 5)
  9. cout<<"It's full,please come again next time! \n";
  10. }
You don't know your basics well.
If statements:
  1. if(condition) {
  2. //code here
  3. }
  4. else {
  5. //code here
  6. }
and check this line again: "warning to cashier\n"; Your forgetting something.
Last edited by Hiroshe; Aug 6th, 2009 at 11:06 am.
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 14
Reputation: spoinkgeek is an unknown quantity at this point 
Solved Threads: 0
spoinkgeek spoinkgeek is offline Offline
Newbie Poster

Re: my assgment-- animal show ticketing system

 
0
  #7
Aug 6th, 2009
if (adults + children < 50)
{
cout<<"warning to cashier \n";
total_amount = (adults * 10) + (children * 5);
cout<<"There are seats available. \n";
}

else if (adults + children > 50)
{
total_amount = (adults * 10) + (children * 5);
cout<<"It's full,please come again next time! \n";
}


these are my if else statement. it's not functioning whenever i put the value big.the cout is not displaying either and also the condition.. how can i correct it? im confused!
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 73
Reputation: dgr231 is on a distinguished road 
Solved Threads: 7
dgr231's Avatar
dgr231 dgr231 is offline Offline
Junior Poster in Training

Re: my assgment-- animal show ticketing system

 
0
  #8
Aug 6th, 2009
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int adults;
  6. int children;
  7. int total_amount;
  8.  
  9. cout<<"Press return after entering a number .\n";
  10. cout<<"Enter the number of adults :\n";
  11. cin>>adults;
  12.  
  13. cout<<"Enter the number of children :\n";
  14. cin>>children;
  15.  
  16. { if (adults + children > 50);
  17. "warning to cashier\n";
  18. total_amount = (adults * 10) + (children * 5)
  19. cout<<"There are seats available. \n";
  20.  
  21.  
  22. else
  23. total_amount = (adults * 10) + (children * 5)
  24. cout<<"It's full,please come again next time! \n";
  25. }
  26.  
  27. cout<<" Animal Show in Zoo Melaka says that ";
  28. cout<<adults;
  29. cout<<"number of adults \n";
  30. cout<< "and ";
  31. cout<<children;
  32. cout<<"number of children, then \n";
  33. cout<< "The total amount that you have to pay is RM ";
  34. cout<<total_amount;
  35.  
  36. system ("pause");
  37. return 0;

I'm still new at coding as well, but it seems to me like the first thing you're going to want to do is place the recurring portions of your program that don't have a set number of times to run (i.e. asking for number of adults, asking for number of children, etc...) in a while loop and then add them for a total. For example:
  1. int adults;
  2. int children;
  3. int totalAdults=0;
  4. int totalChildren=0;
  5. while(totalAdults + totalChildren < 50)
  6. {
  7. cout << "How many adults: \n"
  8. cin >> adults;
  9. totalAdults += adults;
  10.  
  11. cout << "How many children: \n"
  12. cin >> children;
  13. totalChildren += children;
  14. }
You want to issue a warning when you reach 50 tickets, so you'll want the following statement:
  1. if(totalAdults + TotalChildren == 50)
  2. {
  3. cout << "You have sold out this show \n"
  4. << endl;
  5. }
On the other hand, you don't want to oversell tickets, so you're going to want a stipulation in your while loop that says the following:
  1. if(totalAdults + totalChildren > 50)
  2. {
  3. cout << "You have entered more ticktes than you have to sell. \n"
  4. << "Please enter less tickets. \n"
  5. << endl;
  6. }
Finally, you don't want to be forced to sell exactly 50 tickets, so you'll want to include a way to end the sales early. For example:
  1. cout << "To finish entering sales, enter 0 for both children and adults" << endl;
  2.  
  3. if(adults == 0 && children == 0)
  4. {
  5. break;
  6. }

I hope this helps to set you on the right track.

-D
Last edited by dgr231; Aug 6th, 2009 at 12:24 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 14
Reputation: spoinkgeek is an unknown quantity at this point 
Solved Threads: 0
spoinkgeek spoinkgeek is offline Offline
Newbie Poster

Re: my assgment-- animal show ticketing system

 
0
  #9
Aug 6th, 2009
thank you. it really helps. any suggestion on how to insert time slots. my codes are halfway done but incorrect i guess,, guide me in that. i appreciate it.

#include <iostream>
using namespace std;
int main()
{
int x=1;
int y=2;
int response;
cout<<"there are two sessions per day"<<endl;
cout<<"please type 1 for 2pm-4pm session"<<endl;
cout<<"or"<<endl;
cout<<"please type 2 for 8pm-10pm session"<<endl;
cin>>response;
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 73
Reputation: dgr231 is on a distinguished road 
Solved Threads: 7
dgr231's Avatar
dgr231 dgr231 is offline Offline
Junior Poster in Training

Re: my assgment-- animal show ticketing system

 
0
  #10
Aug 6th, 2009
Originally Posted by spoinkgeek View Post
thank you. it really helps. any suggestion on how to insert time slots. my codes are halfway done but incorrect i guess,, guide me in that. i appreciate it.

#include <iostream>
using namespace std;
int main()
{
int x=1;
int y=2;
int response;
cout<<"there are two sessions per day"<<endl;
cout<<"please type 1 for 2pm-4pm session"<<endl;
cout<<"or"<<endl;
cout<<"please type 2 for 8pm-10pm session"<<endl;
cin>>response;
It seems like you're on the right track in terms of getting the time slot wanted. You're going to want to prompt the user as you have with the two choices. In this particular scenario, you don't need the x or y integers. It should probably look something along the lines of this:
  1. int response
  2. cout << "There are two sessions per day. \n"
  3. << "Please type 1 for the 2pm-4pm session \n"
  4. << "or \n"
  5. << "Please type 2 for the 8pm-10pm session:"
  6. << endl;
  7. cin >> response;
  8.  
  9. if(response == 1)
  10. {
  11. //run your code for the first session
  12. }
  13. else if(response == 2)
  14. {
  15. //run your code for the second session
  16. }

-D
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1376 | Replies: 26
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC