Project help

  • (2 Pages)
  • +
  • 1
  • 2

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

#16 PersinArd  Icon User is offline

  • New D.I.C Head

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

Re: Project help

Posted 13 May 2013 - 07:09 AM

i figured it was my loop so i retyped that whole segment of the code that print that part out but its still the same.
Was This Post Helpful? 0
  • +
  • -

#17 jimblumberg  Icon User is offline

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,735
  • Joined: 25-December 09

Re: Project help

Posted 13 May 2013 - 07:36 AM

Please post your complete current code.

Jim
Was This Post Helpful? 0
  • +
  • -

#18 PersinArd  Icon User is offline

  • New D.I.C Head

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

Re: Project help

Posted 13 May 2013 - 07:42 AM

#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;
    switch (choice1)
    {
        case 1:
            cout<<  " loading menue please stand by."<<endl;
            cout<<"    "<<endl;
            cout<<" 100% [=================]" <<endl;
            cout<<"    "<<endl;
            break;
    }
    
    
    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)
	{
        cout << "\n\nPlease enter a choice from the list below:\n"
        << "1. Purchase tickets\n"
        << "2. View total of all ticket sales\n"
        << "3. View total number of seats sold\n"
        << "4. View seats available on a particular row\n"
        << "5. View all available seats\n"
        << "0. Exit\n\n"
        << "Your selection: ";
        
        cin >> choice3;
        
		
		switch(choice3)
		{
                
               
			case 1:
			{
				while(true)
				{
					cout << "\n\nPlease enter your preferred row and seat number,\n"
                    << "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 << "\n*** Invalid seating choice! ***";
                    
					
					else if(available[row][col] == 1)
					{
						available[row][col] = 0;
						seatTotal++;
						salesTotal += price[row];
                        
						
                        
                        
						cout	<< "Thank you for your purchase!"
                        << "\nRow " << (row + 1) << ", seat "
                        << (col + 1) << ", $" << price[row] << "\n\n";
						
                       
						cout << "\n\nAvailable seats are marked with an '#',\n"
                        << "filled seats are marked with an '*'.";
						cout << "\n\n              Seat #\n";
						cout << "       1 2 3 4 5 6 7 8 9 10\n\n";
                        
						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 << "\n\nI'm sorry, that seat has already been filled.";
				}
				choice3 = 5;
				break;
			}
                
                
               
			case 2:
			{
				
                
				cout << "\nTotal ticket sales: $" << salesTotal;
				cout << "\n\n";
			}
                break;
                
              
			case 3:
			{
			
                
				cout << "\nTotal number of seats sold: " << seatTotal;
				cout << "\n\n";
			}
                break;
                
             
			case 4:
			{
				system("cls");
                
				cout << "\n\nEnter a row to view available seating: ";
				cin >> row;
				if (row > ROWs || row < 1)
					cout << "\nInvalid row choice!";
				else
				{
					row -= 1;
                    
				
                    
					cout << "\n\nAvailable seats are marked with an '#',\n"
                    << "filled seats are marked with an '*'.";
					cout << "\n\n\n              Seat #\n";
					cout << "       1 2 3 4 5 6 7 8 9 10\n\n";
                    cout << "Row " << (row + 1) << "  ";
                    
					for (int j = 0; j < COLS; j++)
					{
						if (available[row][j] == 0)
							cout << "* ";
						else
							cout << "# ";
					}
                    cout << "  $" << price[row] << "/seat" << endl;
				}
			}
                break;
                
               
			case 5:
			{
				
                
				cout << "\n\nAvailable seats are marked with an '#',\n"
                << "filled seats are marked with an '*'.";
				cout << "\n\n\n              Seat #\n";
				cout << "       1 2 3 4 5 6 7 8 9 10\n\n";
                
				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;
				}
			}
                break;
                
             
			case 0:
				exit(0);
				break;
				
               
			default:
			{
				
				cout << "\n\n*** Invalid menu choice! ***\n";
			}
		}
        
        
        
	}
	return 0;
}


this the output that i get
Row 1 * # * # # # # # # # * * * * * * * * * * $1/seat
it needs to look like this
Row 1 * # * # # # # # # # $1/seat

i dont know why it does that, i have look over the code and it looks correct and i have rewritten it but i still get the same thing.
Was This Post Helpful? 0
  • +
  • -

#19 jimblumberg  Icon User is offline

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,735
  • Joined: 25-December 09

Re: Project help

Posted 13 May 2013 - 07:52 AM

You declared your variable COLS with a value of 20, why then do you only display 10 seats? Maybe you need to set COLS to equal 10?

Jim
Was This Post Helpful? 0
  • +
  • -

#20 PersinArd  Icon User is offline

  • New D.I.C Head

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

Re: Project help

Posted 13 May 2013 - 08:04 AM

thanks that fixed it. i spent so much time on that it not even funny. i swear if knew who you were i would have bought you a 24 pack.no homo. thanks for the help
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2