I have am either missing a brace or have an extra brace somewhere. This code is also incomplete as I'm still working on the program. The "else" error is a squiggly red line underneath the "else" for the customer does not have a discount coupon.

Thanks!

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <locale>

using namespace std;

int main()

{
    //declare variables

    const double  DISCOUNT         = 0.25;
    double        discountQues     = 0.0;
    double        extraTic         = 0.0;
    const double  JUNIOR_TIC       = 7.50;
    double        juniorTicTotal   = 0.0;
    const double  MAX_SEAT_COUNT   = 2200.0;
    double        numTic           = 0.0;
    const double  SENIOR_TIC       = 11.50;
    double        seniorTicTotal   = 0.0;
    double        ticType          = 0.0;
    const double  TODDLER_TIC      = 0.0;
    double        toddlerTicTotal  = 0.0;
    double        totalCost        = 0.0;
    double        totalNumTic      = 0.0;
    double        totalRevenue     = 0.0;

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

Edited 4 Years Ago by andigirlsc

Usually, fixing the indentation will reveal such problems:

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

See, there is obviously a problem there, you end up three levels of indentation lower than at the start of the while-loop!

This article has been dead for over six months. Start a new discussion instead.