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.

Recommended Answers

All 26 Replies

>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.

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.

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?

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..

#include <iostream>
using namespace std;
int main()
{
    int adults;
    int children;
    int total_amount;
    
    cout<<"Press return after entering a number .\n";
    cout<<"Enter the number of adults :\n";
    cin>>adults;
    
    cout<<"Enter the number of children :\n";
    cin>>children;
    
{ if (adults + children > 50);
       "warning to cashier\n";
        total_amount = (adults * 10) + (children * 5) 
        cout<<"There are seats available. \n";
        
       
 else
        total_amount = (adults * 10) + (children * 5)
        cout<<"It's full,please come again next time! \n";
}        
    
    cout<<" Animal Show in Zoo Melaka says that  ";
    cout<<adults;
    cout<<"number of adults \n";
    cout<< "and ";
    cout<<children;
    cout<<"number of children, then \n";
    cout<< "The total amount that you have to pay is RM ";
    cout<<total_amount;
    
    system ("pause");
    return 0;
    
}

Put your code in code tags

Judging from your code:

{ if (adults + children > 50);
"warning to cashier\n";
total_amount = (adults * 10) + (children * 5)
cout<<"There are seats available. \n";


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

You don't know your basics well.

If statements:

if(condition) {
  //code here
}
else {
  //code here
}

and check this line again: "warning to cashier\n"; Your forgetting something.

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!

#include <iostream>
using namespace std;
int main()
{
    int adults;
    int children;
    int total_amount;
    
    cout<<"Press return after entering a number .\n";
    cout<<"Enter the number of adults :\n";
    cin>>adults;
    
    cout<<"Enter the number of children :\n";
    cin>>children;
    
{ if (adults + children > 50);
       "warning to cashier\n";
        total_amount = (adults * 10) + (children * 5) 
        cout<<"There are seats available. \n";
        
       
 else
        total_amount = (adults * 10) + (children * 5)
        cout<<"It's full,please come again next time! \n";
}        
    
    cout<<" Animal Show in Zoo Melaka says that  ";
    cout<<adults;
    cout<<"number of adults \n";
    cout<< "and ";
    cout<<children;
    cout<<"number of children, then \n";
    cout<< "The total amount that you have to pay is RM ";
    cout<<total_amount;
    
    system ("pause");
    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:

int adults;
int children;
int totalAdults=0;
int totalChildren=0;
while(totalAdults + totalChildren < 50)
{
      cout << "How many adults: \n"
      cin >> adults;
      totalAdults += adults;  
      
     cout << "How many children: \n"
     cin >> children;
     totalChildren += children;
}

You want to issue a warning when you reach 50 tickets, so you'll want the following statement:

if(totalAdults + TotalChildren == 50)
{
      cout << "You have sold out this show \n"
              << endl;
}

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:

if(totalAdults + totalChildren > 50)
{
      cout << "You have entered more ticktes than you have to sell. \n"
              << "Please enter less tickets. \n"
              << endl;
}

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:

cout << "To finish entering sales, enter 0 for both children and adults" << endl;

if(adults == 0 && children == 0)
{
      break;
}

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

-D

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;

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:

int response
cout << "There are two sessions per day. \n"
       << "Please type 1 for the 2pm-4pm session \n"
       << "or \n"
       << "Please type 2 for the 8pm-10pm session:"
       << endl;
cin >> response;

if(response == 1)
{
      //run your code for the first session
}
else if(response == 2)
{
    //run your code for the second session
}

-D

If I may, DO NOT USE system("PAUSE") it calls the system and can only be used on Windows and uses more resources use something better like cin.get();

about that, how if i want to do looping if i don't enter 1 or 2?

about that, how if i want to do looping if i don't enter 1 or 2?

Are you saying that you want to start the program and go directly into the loop for the first show without asking the user which show they want to input for? I'm sorry, but I seem to be a little confused here. Can you layout exactly what you want the user to do from the start of the program to the end?

-D

i mean about the sessions.i wanted to add the loop if i press other number or any character. if u see the output, its written u have choose 1st session, ..... .how to return back to the question on choosing a session? can u get me now?!

and i need ur help in making a kind of receipt that shows number of adults+children, total amount that u should pay and the session u have chosen. example:

cout<<number of adults
cout<<number of children
cout<<total_amount
cout<<session that you've chosen
cout<<enjoy your day with friends and family. thank you

some sort of that.i want to print it on a receipt. can u help me in that way too.thanks again!

Hey, I might be able to help you out! I sent you a private message, so check it and get back to me!

commented: Stop offerering to do other peoples homework for them in private -7

Here is the best outline I can give you for what I know (if I have (below) in the description, then I have provided you with how to do it below the comment. If not, then you need to add your own code.):

#include <iostream>

using namespace std;

int main()
{
	int totalShow1 = 0;
	int totalShow2 = 0;
	while(totalPeople + totalPeople2 < 100)
	{
		int response=0;
		cout << "Please enter 1 for the 2pm show or 2 for \n"
		     << "the 8pm show." << endl;
		cin >> response;
//create integers for adult & child session and adult & child show
//and adult and child day, set them all equal to 0

		if(response != 2 && response != 0)
		{
		
//tell user it is the 1st show and to enter 0 for children and adult 
//to end session
			while(totalShow1<50)
			{

//collect session variable and add them to adult and child show
//variables (for tracking)
//allow user to break session by entering 0s (below)

				if(adults == 0 && children == 0)
				{
					break;
				}
//add adult and child show variable to total show variable
				if(total1>50)
				{
					cout << "You have entered more than 50 people total. \n"
					     << "Please try again. \n"
					     << endl;
//remove last entry from totals as it is no longer applicable
				}
//display session information (below)
				else
				{
					cout << "For " << adults << "adults and " << children << "children," << endl;
					cout << "your total is: RM" << (children * 5) + (adults * 10) << endl;
					cout << "Have a nice day!"
					     << endl;
				}
			}
//show if show is sold out (below)
			if(totalShow1 == 50)
			{
				cout << "The 2pm showing is now full. \n"
				     << endl;
			}	
		
//add total adult and child show to total adult and child day
		}
		
//create variables for total adult and child for 2nd show

		if(response == 2)
		{
//do everything you did for the first show
		}
//close your original while loop
                  }
//display results for the day (below)
              cout << "Today, we sold " << totalDayAdults << "adult tickets \n
                     << "and " << totalDayChildren << "children tickets for a total of: \n"
	     << (totalDayAdults * 10) + (totalDayChildren * 5) << endl;

	cout << "See you tomorrow!"
	        << endl;
	return 0;
}

It is a little messy, but it should outline everything you need to do to get the program up and running.

-D

thanks for the codes.i have a problem in the codes that u gave me.. how does the else statement at the end works? because when i put 50 adults, 50 children it says that more tickets has entered.. how does it end? any suggestion?

#include <iostream>
using namespace std;
int main()
{

int adults;
int children;
int totalAdults=0;
int totalChildren=0;

while(totalAdults + totalChildren < 50)
{
      cout << "How many adults: \n";
      cin >> adults;
      totalAdults += adults;  

     cout << "How many children: \n";
     cin >> children;
     totalChildren += children;

     if(totalAdults + totalChildren <= 50)
{
      cout << "You have reach the maximum for the day\n"
              << endl;
}

    else if(totalAdults + totalChildren >= 50)
{
      cout << "You have entered more ticktes than you have to sell. \n"
              << "Please enter less tickets. \n"
              << endl;
}
    else
     cout << "To finish entering sales, enter 0 for both children and adults" << endl;

if(adults == 0 && children == 0)
{
      break;
}


     system ("pause");
    return 0;
}
}

hello.. about this codes, it works fine but how to continue from the codes to the beginning of the receipt. like example.. press Y or N to continue.. it comes back to the beginning which was the welcoming and how many adults and children... can u help on that??

#include<iostream>
using namespace std;
int main()
{
    int response;

cout << "There are two sessions per day. \n"
       << "Please type 1 for the 2pm-4pm session \n"
       << "or \n"
       << "Please type 2 for the 8pm-10pm session "
       << endl;
cin >> response;

if(response == 1)
{
      cout<<"You have choosed 1st session\n\nat 2pm-4pm.\n\nThank you and have a nice day\n"<<endl;

}
else if(response == 2)
{
    cout<<"You have choosed 2nd session\n\nat 8pm-10pm.\n\nThank you and have a nice day\n"<<endl;
}

else (response > 3);
     cout<<"please press either 1 or 2 "<<endl;


 system("pause");
 return 0;
}

As I am still a beginner at c++ myself, I'm not entirely positive how to access external hardware to print a receipt, but in order to get receipt text to appear on the screen, you would want to have something similar to the following at the end of each session code:

string sReceiptAnswer;

cout << "Please press Y for a receipt or N to pass."
       << endl;
getline(cin,sReceiptAnswer);

if(sReceiptAnswer.compare('y') == 0 || sReceiptAnswer.compare('Y') == 0)
{
      //print receipt
}
else if(sReceiptAnswer.compare('n') == 0 || sReceiptAnswer.compare('N') == 0)
{
     //go back to enter session id
}
else 
{
      cout << "You did not answer Y or N"
              << endl;
}

-D

woww...nice post btw..can someone show me full coding...need to learn more..

thanks

i really appreaciate it! thanx lot man.. it is useful for me. good job

#include <iostream>
using namespace std;
int main ()
{
    int adults1, children1, adults2, children2, total_adults, total_childrens, selection, total_ticket1 = 0, total_ticket2 = 0, sessions;

    int total_sales = ( total_ticket1 + total_ticket2 );






    sessions = 0;
    cout << " Please select one of these sessions : " << endl;
    cout << " Press in 1 for 2pm to 4pm session " << endl;
    cout << " Press in 2 for 8pm to 10pm session " << endl;
    cin >> sessions ;


        if ( sessions == 1 && sessions != 0 ) 
        {

        cout << " Zoo Melaka presents you Animal Show " << endl;
        cout << " This is 2pm to 4pm session " << endl;
        cout << " To exit, key in 0 for both adults and children " << endl; 

            while ( total_ticket1 < 50 ) {
                int adult1, children1;
                cout << " Number of adults " << endl;
                cin >> adults1;
                total_ticket1 += adults1;
                cout << " Number of children " << endl;
                cin >> children1;
                total_ticket1 += children1;

                    if ( adults1 == 0 && children1 == 0 ) break; 

                else {

                int adultstotal_1 = ( adults1 * 10);
                int childrentotal_1 = ( children1 * 5);
                int total = ( total_adults + total_childrens);
                int ticket1 = (adults1+children1);
                cout << " The total amount is  RM " << total << endl;

                    }





                 if  ( total_ticket1 > 50 ){
                    cout << " Exceed total ticket allowed !! " << endl;
                    cout << " Please key in less ticket :" << endl;
                }

                else if  ( total_ticket1 == 50 ) {
                    cout << " Warning!! The ticket was sold out " << endl;
                    cout << " Please come again! " <<endl;
                }


                    int selection;
                    int total_sales = (total_ticket1 + total_ticket2);
                    cout << " Press 1 to continue " << endl;
                    cout << " Press 2 to exit " << endl;
                    cin >> selection;

                    if ( selection == 2 ) break;

                    else if ( selection == 1 ){
                        cout << " Total ticket that had been sold are " << total_ticket1 << endl;
                        cout << " Total ticket sold by today are " << total_sales << endl;
                    }
                        system("pause"); 
                }   
          }     
            if ( sessions == 2 && sessions != 0 ) {

                    cout << " Zoo Melaka presents you Animal Show " << endl;
                    cout << " This is 8pm to 10pm session " << endl;
                    cout << " To exit, key in 0 for both adults and children " << endl; 


            while ( total_ticket2 < 50 ) {
                int adult2, children2;
                cout << " Number of adults " << endl;
                cin >> adults2;
                total_ticket2 += adults2;
                cout << " Number of children " << endl;
                cin >> children2;
                total_ticket2 += children2;

                    if ( adults2 == 0 && children2 == 0 ) break; 

                else {

                int adultstotal_2 = ( adults2 * 10);
                int childrentotal_2 = ( children2 * 5);
                int total = ( adultstotal_2+childrentotal_2);
                int ticket2 = (adults2 + children2);
                cout << " The total amount is  RM " << total << endl;

                int choices;
                cout << " Do you want to print  a receipt? " << endl;
                cout << " Press  1 to print receipt " <<endl;
                cout << " Press  2 to exit " << endl;
                cin >> selection;
                    if ( selection != 1 || selection == 2 )break;

                    else if ( selection == 1 || selection != 2 ){
                        cout << "The receipt for the transaction is:" << endl;
                        cout << "Adult      " << adults2  << "    RM" << adultstotal_2 << endl;
                        cout << "Children   " << children2 << "    RM" << childrentotal_2 << endl;
                        cout << "Total      " << ticket2 << "    RM" << total << endl;
                    }       
                system("pause"); 


                      }      


          }



return 0;
}
}

this is the full coding. but there's a small error on the total_amount for 1st session.. As far it is,, the rest are perfect.. mayb u can try debug and run it..

else {

int adultstotal_1 = ( adults1 * 10);
int childrentotal_1 = ( children1 * 5);
int total = ( total_adults + total_childrens);
int ticket1 = (adults1+children1);
cout << " The total amount is RM " << total << endl;

}

for the 1st session..check the int declare

There are a couple of places where you need to make sure you have your curved brackets {encapsulating your code}. Namely after your if statements:

if ( adults1 == 0 && children1 == 0 ) break; 
//and//
if ( selection == 2 ) break;

Should be:

if(adults1 == 0 && children1 == 0)
{
      break;
}
//and//
if(selection == 2)
{
     break;
}

I don't really have the time to fully debug your program, but feel free to post any errors or problems and I will attempt to help you with them.

-D

#include<iostream>
#include<iomanip>

using namespace std;

const double ADULTPRICE = 10.00;
const double CHILDPRICE = 5.00;
static int SHOW1_ADULT = 0;
static int SHOW2_ADULT = 0;
static int SHOW1_CHILD = 0;
static int SHOW2_CHILD = 0;
static int SHOW1_TOTAL = 50;
static int SHOW2_TOTAL = 50;
static int FLAG = 0;

void Show2PM();
void Show8PM();
void PrintSales();

//main function
int main()
{
	//variable for the number they pick.
	int selection;

	//while loop used to make sure the program does not exit until it is suppose to.
	while (FLAG == 0)
	{
	cout << "Welcome to the Animal Show!! Select from the following options: " << endl;
	cout << endl;
	if (SHOW1_TOTAL <= 10 && SHOW1_TOTAL > 0)
	{
		cout << "(1) Buy tickets for 2:00 P.M. show. - ONLY " << SHOW1_TOTAL << " TICKETS REMAIN!"  << endl;
	}
	//displays if the show is sold out, or SHOW1_TOTAL is at 0.
	else if (SHOW1_TOTAL == 0)
	{
		cout << "THIS SHOW IS SOLD OUT! NO TICKETS AVAILABLE!!!" << endl;
	}
	else
	{
		cout << "(1) Buy tickets for 2:00 P.M. show." << endl;
	}
	if (SHOW2_TOTAL <= 10 && SHOW2_TOTAL > 0)
	{
		cout << "(2) Buy tickets for 2:00 P.M. show. - ONLY " << SHOW2_TOTAL << " TICKETS REMAIN!"  << endl;
	}
	//displays if the show is sold out, or SHOW2_TOTAL is at 0.
	else if (SHOW2_TOTAL == 0)
	{
		cout << "THIS SHOW IS SOLD OUT! NO TICKETS AVAILABLE!!!" << endl;
	}
	else
	{
		cout << "(2) Buy tickets for 8:00 P.M. show." << endl;
	}
	cout << "(3) Print a sales report." << endl;
	cout << "(4) Terminate the program." << endl << endl;

	//get the seleciton they choose.
	cin >> selection;
	
	//users presses 1 and program goes to the function.
	if (selection == 1)
	{
		Show2PM();
	}

	//users presses 2 and program goes to the function.
	else if (selection == 2)
	{
		Show8PM();
	}

	//users presses 3 and program goes to the function.
	else if (selection == 3)
	{
		PrintSales();
	}

   //when the user presses 4, the program will terminate. all values are reset.
	else if (selection == 4)
	{
		return 0;
	}

	else
	{
		cout << "You did not enter a correct number." << endl;
	}
    
	//pause makes you hit enter to continue, and "cls" clears the command prompt out.
	system("PAUSE");
	system("cls");

	}

	
	return 0;
}
//function called when the user enters 1. contains all the info for the 2 pm show.
void Show2PM()
{
	system("cls");
	int numAdults;
	int numChildren;
	double AdultTotal;
	double ChildTotal;
	
	cout << endl << "2:00 PM Show: " <<  SHOW1_TOTAL << " tickets remain for the show." << endl;
	cout << "Enter the number of adults: " << endl;
	cin >> numAdults;
	cout << "Enter the number of children: " << endl;
	cin >> numChildren;

	//this event happens if you try to sell more tickets than you have
	if ((numAdults + numChildren) > SHOW1_TOTAL)
	{
		cout << "There are not enough tickets remaining for this order. Please try another show." << endl << endl;
	}

	else
	{

	AdultTotal = numAdults * ADULTPRICE;
	ChildTotal = numChildren * CHILDPRICE;

	SHOW1_TOTAL = SHOW1_TOTAL - (numAdults + numChildren);
	SHOW1_ADULT = SHOW1_ADULT + numAdults;
	SHOW1_CHILD = SHOW1_CHILD + numChildren;

    cout << fixed << showpoint;
    cout << setprecision(2);
	cout << endl << "----------" << endl;
	cout << "Animal Show 2:00 P.M." << endl;
	cout << "Adult Charge: " << AdultTotal << endl;
	cout << "Child Charge: " << ChildTotal << endl;
	cout << "Total Charge: " << ChildTotal + AdultTotal << endl;
	cout << "Please ENJOY THE SHOW!!!" << endl;
	//cout << "There are " << SHOW1_TOTAL << " tickets remaining for the show." << endl;
	cout << "----------" << endl << endl;
	}


}
//function called when the user enters 2. contains all the info for the 8 pm show.
void Show8PM()
{
	system("cls");
	int numAdults;
	int numChildren;
	double AdultTotal;
	double ChildTotal;
	
	cout << endl << "8:00 PM Show: " <<  SHOW2_TOTAL << " tickets remain for the show." << endl;
	cout << "Enter the number of adults: " << endl;
	cin >> numAdults;
	cout << "Enter the number of children: " << endl;
	cin >> numChildren;
	
	//this event happens if you try to sell more tickets than you have
	if ((numAdults + numChildren) > SHOW2_TOTAL)
	{
		cout << "There are not enough tickets remaining for this order. Please try another show." << endl << endl;
	}

	else
	{

	AdultTotal = numAdults * ADULTPRICE;
	ChildTotal = numChildren * CHILDPRICE;

	SHOW2_TOTAL = SHOW2_TOTAL - (numAdults + numChildren);
	SHOW2_ADULT = SHOW2_ADULT + numAdults;
	SHOW2_CHILD = SHOW2_CHILD + numChildren;

    cout << fixed << showpoint;
    cout << setprecision(2);
	cout << endl << "----------" << endl;
	cout << "Animal Show 8:00 P.M." << endl;
	cout << "Adult Charge: " << AdultTotal << endl;
	cout << "Child Charge: " << ChildTotal << endl;
	cout << "Total Charge: " << ChildTotal + AdultTotal << endl;
	cout << "Please ENJOY THE SHOW!!!" << endl;
	//cout << "There are " << SHOW2_TOTAL << " tickets remaining for the show." << endl;
	cout << "----------" << endl << endl;
	}

}
//function called to print all the sales for the day.
void PrintSales()
{
	system("cls");
	cout << fixed << showpoint;
    cout << setprecision(2);

	cout << endl << "Animal Show Print Page" << endl << endl; 
	cout << "----------" << endl; 
	cout << "Show Time: 2:00 P.M." << endl; 
	cout << "Number of adults attending: " << SHOW1_ADULT << endl;
	cout << "Total Adult Charges: " << SHOW1_ADULT * ADULTPRICE << endl; 
	cout << "Number of children attending: " << SHOW1_CHILD << endl;
	cout << "Total Child Charges: " << SHOW1_CHILD * CHILDPRICE << endl << endl;
	cout << "TOTAL TICKETS SOLD: " << SHOW1_ADULT + SHOW1_CHILD << endl;
	cout << "TOTAL TICKET SALE AMOUNT: " << (SHOW1_ADULT * ADULTPRICE) + (SHOW1_CHILD * CHILDPRICE) << endl;
	cout << "----------" << endl << endl; 

	cout << "Show Time: 8:00 P.M." << endl; 
	cout << "Number of adults attending: " << SHOW2_ADULT << endl;
	cout << "Total Adult Charges: " << SHOW2_ADULT * ADULTPRICE << endl; 
	cout << "Number of children attending: " << SHOW2_CHILD << endl;
	cout << "Total Child Charges: " << SHOW2_CHILD * CHILDPRICE << endl << endl;
	cout << "TOTAL TICKETS SOLD: " << SHOW2_ADULT + SHOW2_CHILD << endl;
	cout << "TOTAL TICKET SALE AMOUNT: " << (SHOW2_ADULT * ADULTPRICE) + (SHOW2_CHILD * CHILDPRICE) << endl;
	cout << "----------" << endl << endl; 

}

It doesn't really make sense to me why you would use doubles in this particular program. The adult and children prices for tickets are $10 and $5, respectively, and because the user can not purchase a fraction of a ticket, you will never end up with a decimal. I could understand this if we are informed that the prices of tickets may change, but we don't have any information suggesting this. It would make more sense to me to use an int or even a short int because you will never end up with a number above 1000 (100 adult tickets @ $10 per ticket) for any value in this program.

const double ADULTPRICE = 10.00;
const double CHILDPRICE = 5.00;

double AdultTotal;
double ChildTotal;

//versus

const int nAdultPrice = 10;
const int nChildPrice = 5;

int nAdultTotal, nChildTotal;

-D

*Shrugs* I have always used double when I deal with monetary values. Likw you said, if you wanted to change the prices, you wouldn't have to re-write code...

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.