The else statement for "the customer does not have a discount coupon is underlined as incorrect. There is a missing or extra brace somewhere, but I can't find it. Also, keep in my that my program is unfinished.
//welcome the user and explain the purpose of the software
int consoleWidth = 50;
cout << setw(consoleWidth / 2) << " " << " PRIOLEAU PROGRAMMING, INC " << endl;
cout << setw(consoleWidth / 2) << " " << "SUMMERVILLE SEAWORLD TICKETING SOFTWARE 1.0" << endl << endl;
cout << "This program is designed to control, manage and track "
"ticket sales for Summerville Seaworld. Please input information when "
"you are prompted. Enjoy!" << endl << endl;
//choose a type of ticket
cout << "Please select from the following types of tickets: " << endl << endl;
cout << "TICKET TYPE AGE RANGE COST" << endl;
cout << "Toddler 0-5 years Free" << endl;
cout << "Junior 6-16 years $7.50" << endl;
cout << "Senior 17 and up $11.50" << endl;
cout << endl << endl;
cout << "Which type of ticket would you like to purchase? (1, 2, 3 or 4): " << endl;
cin >> ticType;
cout << endl;
//ticket purchase while loop
while (ticType == 1 || ticType == 2 || ticType == 3)
{//while the ticket type equals 1, 2 or 3
if (ticType == 1)
{//if purchase toddler ticket
cout << "You have selected to purchase a Toddler ticket. "
"How many Toddler tickets would you like to buy?" << endl << endl;
cout << "Please enter the number of tickets (1-10): " << endl << endl;
cin >> numTic;
}
if (numTic > 0 && numTic <= 10)
{//if number of toddler tickets is between 1-10
cout << "Do you have a discount coupon today?" << endl;
cout << "Enter 1 for YES or 2 for NO: " << endl;
cin >> discountQues;
}
if (discountQues == 1)
{//if customer has a discount coupon
totalCost = (TODDLER_TIC * numTic) - (TODDLER_TIC * numTic * DISCOUNT);
totalNumTic += numTic;
totalRevenue += totalCost;
}
if (totalNumTic >= MAX_SEAT_COUNT)
{//if the total number of tickets equals the maximum seat count
extraTic = totalNumTic - MAX_SEAT_COUNT;
cout << "SEAT CAPACITY EXTRAS TOTAL SOLD" << endl;
cout << MAX_SEAT_COUNT << extraTic << totalNumTic;
cout << "TODDLERS JUNIORS SENIORS";
cout << toddlerTicTotal << juniorTicTotal << seniorTicTotal;
cout << "GROSS FOR TODAY: $" << totalRevenue << endl << endl;
}
else
{//else the total number of tickets does not equal the maximum seat count
cout << "Type of ticket(s): Toddler Ticket(s)"<< endl;
cout << "Number of ticket(s):" << numTic << endl;
cout << "Total Cost: " <<totalCost << endl;
}
else
{//else the customer does not have a discount coupon
totalCost = TODDLER_TIC * numTic;
totalNumTic += numTic;
totalRevenue += totalCost;
}
else
{//else the number of tickets is not between 1-10
cout << "The maximum number of tickets that can be sold "
" is 10. Please enter a number between 1-10." << endl;
cin >> numTic;
}
else if (ticType == 2)
{
}
else if (ticType == 3)
{
}// end if
}//end while
system("pause");
return 0;
} //end of main function
if (totalNumTic >= MAX_SEAT_COUNT)
{//if the total number of tickets equals the maximum seat count
extraTic = totalNumTic - MAX_SEAT_COUNT;
cout << "SEAT CAPACITY EXTRAS TOTAL SOLD" << endl;
cout << MAX_SEAT_COUNT << extraTic << totalNumTic;
cout << "TODDLERS JUNIORS SENIORS";
cout << toddlerTicTotal << juniorTicTotal << seniorTicTotal;
cout << "GROSS FOR TODAY: $" << totalRevenue << endl << endl;
}
else
{//else the total number of tickets does not equal the maximum seat count
cout << "Type of ticket(s): Toddler Ticket(s)"<< endl;
cout << "Number of ticket(s):" << numTic << endl;
cout << "Total Cost: " <<totalCost << endl;
}
else
{//else the customer does not have a discount coupon
totalCost = TODDLER_TIC * numTic;
totalNumTic += numTic;
totalRevenue += totalCost;
}
else
{//else the number of tickets is not between 1-10
cout << "The maximum number of tickets that can be sold "" is 10. Please enter a number between 1-10." << endl;
cin >> numTic;
}
You have else statements without the if statements to accompany them. Try elseif statements.
Where does the missing if need to be? I have several ifs to go into before I can begin else statements. Don't have have to go into all of the ifs first? I wish I could post my flowchart.
if (ticType == 1)
{//if purchase toddler ticket
...
}
if (numTic > 0 && numTic <= 10)
{//if number of toddler tickets is between 1-10
...
}
if (discountQues == 1)
{//if customer has a discount coupon
...
}
if (totalNumTic >= MAX_SEAT_COUNT)
{//if the total number of tickets equals the maximum seat count
...
}
else
{//else the total number of tickets does not equal the maximum seat count
...
}
else
{//else the customer does not have a discount coupon
...
}
else
{//else the number of tickets is not between 1-10
...
}
elseif (ticType == 2)
{
}
I think what you are trying to do is nest the if statements. You've got your closing braces at the end of your if statements in the wrong places. What you want is:
if (ticType == 1)
{//if purchase toddler ticket
...
if (numTic > 0 && numTic <= 10)
{//if number of toddler tickets is between 1-10
...
if (discountQues == 1)
{//if customer has a discount coupon
...
if (totalNumTic >= MAX_SEAT_COUNT)
{//if the total number of tickets equals the maximum seat count
...
}
else
{//else the total number of tickets does not equal the
//maximum seat count
...
}
}
else
{//else the customer does not have a discount coupon
...
}
}
else
{//else the number of tickets is not between 1-10
...
}
}
elseif (ticType == 2)
{
}
Notice each successive if statement is contained within the previous if statement code block.