Project help

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 641 Views - Last Post: 13 May 2013 - 08:04 AM Rate Topic: -----

#1 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Project help

Posted 12 May 2013 - 02:44 PM

that last menu just keep repeating itself no matter the input.

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

    int choice1=1;
    int choice2=1;
    int choice3=1;
    
    
    
    const int COLS =20;
    const int ROWs =5;
   	double price[ROWs];
	bool available[ROWs][COLS]={
        {1,1,1,1,1,1,1,1,1,1},
        {1,1,1,1,1,1,1,1,1,1},
        {1,1,1,1,1,1,1,1,1,1},
        {1,1,1,1,1,1,1,1,1,1},
        {1,1,1,1,1,1,1,1,1,1}};
  
    int seatTotal = 0;
	double salesTotal = 0;
	int row, col;
  
     cout<< "  ||*******************************||"<<endl;
     cout<< "  ||                               ||"<<endl;
     cout<< "  ||   WECLCOME TO TICKETMASTER    ||"<<endl;
     cout<< "  ||                               ||"<<endl;
     cout<< "  ||*******************************||"<<endl;
    
	cout<< "Thank you for using our program to setup your"<<endl;
    cout<< "Theaters seating and pricing.As always our tech support"<<endl;
    cout<< "staff are ready to assist you with any issues."<<endl;;
    cout<< "Would you like to start this porgram? (1 or 0)"<<endl;
    cin>>choice1;
   if (choice1==1)
    {
        cout<<  " loading menue please stand by."<<endl;
        cout<<"    "<<endl;
        cout<<" 100% [=================]" <<endl;
        cout<<"    "<<endl;
    }
    
    
   if(choice1 ==0)
   {
        cout<<"loging you out.";
        return 0;
   }
    
    cout<<" would you like to view youre theaters seating chart while"<<endl;
    cout<<"entering prices  setting up prices?(1 or 0)"<<endl;
    cin>>choice2;
    
    if (choice2==1)
    {
        cout<<  " loading seating chart please stand by."<<endl;
        cout<<" 100% [=================]" <<endl;

        
        
        cout << "                           1 2 3 4 5 6 7 8 9 10\n\n";
        cout << "                     Row 1 # # # # # # # # # #  "<<endl;
        cout << "                     Row 2 # # # # # # # # # #  "<<endl;
        cout << "                     Row 3 # # # # # # # # # #  "<<endl;
         cout <<"                     Row 4 # # # # # # # # # #  "<<endl;
         cout <<"                     Row 5 # # # # # # # # # #  "<<endl;
        cout<<"     "<<endl;
    }

     if (choice2==0)
          {
              cout<<"Please enter a price for each row."<<endl;
            }
    
    for (int count = 0; count < ROWs; count++)
	{
		cout << "Please enter seat prices for row "<<endl;cout << (count+1) << ":  $";
		cin >> price[count];
	}
    
    cout<<"    "<<endl;
    cout << "Updating youre updated theaters seating chart."<<endl;
   
             cout<<  "Loading please stand by."<<endl;
        cout<<" 100% [=================]" <<endl;
        cout<<"      "<<endl;
        
       
        for (int count = 0; count < ROWs; count++)
        {
            cout << "ROW  "<<(count+1)<<"  # # # # # # # # # #"<< ":  $";
            cout<< price[count]<<endl;
            cout<<"   "<<endl;
        }
    
    
    while (choice3 != 0)
	{
///////here  is the repeating menu.///
            cout << "You're Theater's pricing is complete you may now begin testing the program: "<<endl;
            cout<< "1. Purchase tickets"<<endl;
            cout << "2. View total of all ticket sales"<<endl;
            cout << "3. View total number of seats sold"<<endl;
            cout<< "4. View seats available on a particular row"<<endl;
            cout<< "5. View all available seats"<<endl;
            cout<< "0. Exit"<<endl;
            cout<< "Your selection: "<<endl;
            
            cin >> choice3;
        }

    
            switch(choice3)
            {
        
                case 1:
                {
                    while(true)
                    {
                        cout << "Please enter your preferred row and seat number"<<endl;
                        cout<< "separated by a space, or a 0 (zero) to exit: ";
                        cin >> row;
                        
                        if (row == 0)
                            
                            break;
                        
                        cin	>> col;
                        
                        row -= 1;
                        col -= 1;
                        
                
                        if ( row > (ROWs - 1) || row < 0 || col > (COLS-1) || col < 0)
                            cout << "*** Invalid seating choice! ***";
                    
                        else if(available[row][col] == 1)
                        {
                            available[row][col] = 0;
                            seatTotal++;
                            salesTotal += price[row];
                            
                            system("cls");
                            
                            cout	<< "Thank you for your purchase!"
                            << "nRow " << (row + 1) << ", seat "
                            << (col + 1) << ", $" << price[row] <<endl;
                            
                            cout << "Available seats are marked with an '#',"<<endl;
                            cout<< "filled seats are marked with an '*'.";
                            cout << "              Seat #"<<endl;
                            cout << "       1 2 3 4 5 6 7 8 9 10"<<endl;
                            
                            for (int i = 0; i < ROWs; i++)
                            {
                                cout << "Row " << (i + 1) << "  ";
                                for (int j = 0; j < COLS; j++)
                                {
                                    if (available[i][j] == 0)
                                        cout << "* ";
                                    else
                                        cout << "# ";
                                }
                                cout << " $" << price[i] << "/seat" << endl;
                            }
                        }
                        
                   
                        else
                            cout << "I'm sorry, that seat has already been filled.";
                    }
                    choice3 = 5;
              
                }
                    
                    
                case 2:
                {
                    system("cls");
                    
                    cout << "Total ticket sales: $" << salesTotal;
                    cout << "  "<<endl;
                }
             
                  
                case 3:
                {
                    system("cls");
                    
                    cout << "Total number of seats sold: " << seatTotal;
                    cout << "  "<<endl;
                }
                
                  
                case 4:
                {
                    system("cls");
                    
                    cout << "Enter a row to view available seating: ";
                    cin >> row;
                    if (row > ROWs || row < 1)
                        cout << "nInvalid row choice!";
                    else
                    {
                        row -= 1;
                        
                        system("cls");
                        
                        cout << "Available seats are marked with an '#',"<<endl;
                        cout<< "filled seats are marked with an '*'.";
                        cout << "              Seat #"<<endl;
                        cout << "       1 2 3 4 5 6 7 8 9 10"<<endl;
                        cout << "Row " << (row + 1) << "  ";
                        
                        for (int j = 0; j < COLS; j++)
                        {
                            if (available[row][j] == 0)
                                cout << "* ";
                            else
                                cout << "# ";
                        }
                        cout << "  $" << price[row] << "/seat" << endl;
                    }
                }
                   
                    
                case 5:
                {
                    system("cls");
                    
                    cout << "Available seats are marked with an '#',"<<endl;
                    cout<< "filled seats are marked with an '*'.";
                    cout << "              Seat #";
                    cout << "       1 2 3 4 5 6 7 8 9 10"<<endl;
                    
                    for (int i = 0; i < ROWs; i++)
                    {
                        cout << "Row " << (i + 1) << "  ";
                        
                        for (int j = 0; j < COLS; j++)
                        {
                            if (available[i][j] == 0)
                                cout << "* ";
                            else
                                cout << "# ";
                        }
                        
                        cout << "  $" << price[i] << "/seat" << endl;
                    }
                }
                 
                    
                    
                case 0:
                    exit(0);
                    break;
                    
                    
                default:
                {
                    system("cls");
                    cout << "*** Invalid menu choice! ***"<<endl;
                }
            }
            
            
            
        
        
    
    
}



Is This A Good Question/Topic? 0
  • +

Replies To: Project help

#2 Skyla Blue  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 01-May 13

Re: Project help

Posted 12 May 2013 - 02:47 PM

What is the last menu? Kind of hard to discern that from looking at your code.
Was This Post Helpful? 0
  • +
  • -

#3 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 02:51 PM

sorry i put ////here is the repeating menu right above the menu that keeps repeating no mater the input.
Was This Post Helpful? 0
  • +
  • -

#4 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 02:57 PM

here is the menu that repeats.

cout << "You're Theater's pricing is complete you may now begin testing the program: "<<endl;
            cout<< "1. Purchase tickets"<<endl;
            cout << "2. View total of all ticket sales"<<endl;
            cout << "3. View total number of seats sold"<<endl;
            cout<< "4. View seats available on a particular row"<<endl;
            cout<< "5. View all available seats"<<endl;
            cout<< "0. Exit"<<endl;
            cout<< "Your selection: "<<endl;
            


Was This Post Helpful? 0
  • +
  • -

#5 Skyla Blue  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 01-May 13

Re: Project help

Posted 12 May 2013 - 03:13 PM

Your problem is, you aren't checking for a break, just repeating. while(choices3 != 0) will always be true, because you have int choice3=1;
Was This Post Helpful? 0
  • +
  • -

#6 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 03:18 PM

yeah but when i set it to 1 it completly skips the menu and jumsps to the next set of statements.
Was This Post Helpful? 0
  • +
  • -

#7 Skyla Blue  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 01-May 13

Re: Project help

Posted 12 May 2013 - 03:27 PM

Why don't you use a switch statement to check the input of choice1? That would be a lot easier to do. So, you could do this

cin >> choice1;

switch(choice1)
{
case 1:
/* print your menu */
break;
etc.
}
Was This Post Helpful? 0
  • +
  • -

#8 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 03:43 PM

that also works for choice1, but my problem is where choice3 gets inputed which just keep repeating the menu. i tried you're switch statement for choice3 but i just skipped it.
Was This Post Helpful? 0
  • +
  • -

#9 Skyla Blue  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 01-May 13

Re: Project help

Posted 12 May 2013 - 03:46 PM

Well, you don't appear to be asking for choice3, so how can you create a switch statement with it?
Was This Post Helpful? 0
  • +
  • -

#10 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 03:55 PM

i have its in my first post on line 113.
Was This Post Helpful? 0
  • +
  • -

#11 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1396
  • View blog
  • Posts: 4,865
  • Joined: 19-February 09

Re: Project help

Posted 12 May 2013 - 04:26 PM

You want to stay in the loop while choice3 is not 0, 1, 2, 3, 4, or 5, and leave when it is one of them. That is a range of values. One problem is you initialize choice3 to 1, if you initialize just before the loop that would help, or use a do..while loop. Functions can help break up code into managable parts.
Was This Post Helpful? 0
  • +
  • -

#12 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 05:19 PM

thanks for the help. i switched to if statment and initialized to ==1. whci worked. i just need help getting back to the menue because after a few options it just stops.
Was This Post Helpful? 0
  • +
  • -

#13 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1396
  • View blog
  • Posts: 4,865
  • Joined: 19-February 09

Re: Project help

Posted 12 May 2013 - 07:23 PM

You need a loop.

Function might help.
Functions (I)
Was This Post Helpful? 0
  • +
  • -

#14 PersinArd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-April 13

Re: Project help

Posted 12 May 2013 - 10:55 PM

thank you for the help. i have another problem in the output. i get Row 1 * # # # # # # # # # * * * * * * * * * * $1/seat it supposed to look like Row 1 * # # # # # # # # # $1/seat. ay ideas how to fix that?
Was This Post Helpful? 0
  • +
  • -

#15 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3650
  • View blog
  • Posts: 11,419
  • Joined: 05-May 12

Re: Project help

Posted 13 May 2013 - 05:14 AM

What have you done to try to fix it?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2