I'm doing a program that shows which tickets have been sold for an auditorium. I am a beginner to c++ so I am not sure how I can do the following:

a) Allocate an input with a character (e.g. when I enter 'A10' .. how do I allocate 'A' to an integer input?)

b) How to show, on a 2-D array, when a spot has been sold (e.g. if I enter 'A10', how do I erase that spot off the board?)

I've read lots of tutorials but it's just those 2 things that I am unclear on.

Here is my current program. It's basically static at the moment:

#include<iostream>
#include<iomanip>
#include<string>

using namespace::std;

int aud[19][24];
char change;

double Total_Sales;
char database[20][20];


int output()
{
    char Letter;
    int database;
    for(int x=0;x<=24;x++)
    {
       for(int y=0;y<=19;y++)
       cout<<" x";
       cout<<endl;
    }

  for(int Outer_Loop = 0;Outer_Loop<=25;Outer_Loop++)
        { 
            for(int Seats_Letter_Display = 1;Seats_Letter_Display <=1;Seats_Letter_Display++)  
            {

                    switch(Letter)
                    {
                          case 1:cout<<" A"; break;
                          case 2:cout<<" B"; break;
                          case 3:cout<<" C"; break;
                          case 4:cout<<" D"; break;
                          case 5:cout<<" E"; break;
                          case 6:cout<<" F"; break;
                          case 7:cout<<" G"; break;
                          case 8:cout<<" H"; break;
                          case 9:cout<<" I"; break;
                          case 10:cout<<" J"; break;
                          case 11:cout<<" K"; break;
                          case 12:cout<<" L"; break;
                          case 13:cout<<" M"; break;
                          case 14:cout<<" N"; break;
                          case 15:cout<<" O"; break;
                          case 16:cout<<" P"; break;
                          case 17:cout<<" Q"; break;
                          case 18:cout<<" R"; break;
                          case 19:cout<<" S"; break;
                          case 20:cout<<" T"; break;   

                    }
                    Letter++; 
            }  

        }


}

int main()
{

    float AE,FK,LT;
    float AE_sold,FK_sold,LT_sold;
    int row;
    char column;
    double S1 = 12.00;
    double S2 = 8.50;
    double S3 = 6.50;

    output();

    cout<<"\nCurrent Prices: ";
    cout<<S1;
    cout<<S2;
    cout<<S3;

    cout <<"\n\nEnter the price for A-E: $";
    cin >> AE;
    cout << "";
    cout <<"Enter the price for F-K: $";
    cin >> FK;
    cout << "";
    cout <<"Enter the price for L-T: $";
    cin>>LT;
    cout<<"";

    cout<<"\n\nSelect a column letter: ";
    cin>>column;
        cout<<"Select a row number: ";
    cin>>row;
        system("PAUSE");
        return 0;
}

I'm doing a program that shows which tickets have been sold for an auditorium. I am a beginner to c++ so I am not sure how I can do the following:

a) Allocate an input with a character (e.g. when I enter 'A10' .. how do I allocate 'A' to an integer input?)

b) How to show, on a 2-D array, when a spot has been sold (e.g. if I enter 'A10', how do I erase that spot off the board?)

Have 'A' be 0, 'B' be 1, 'C' be 2, etc. To convert from 'A' to 0, subtract 65. 65 is the ASCII value of 'A'.

#include <iostream>
using namespace std;

int main ()
{
    char letter;
    cout << "Enter a letter for row : ";
    cin >> letter;
    int row = letter - 65;
    cout << "Row " << letter << " is index " << row << endl;

    return 0;
}

you can try something as below....

#include<iostream>
using namespace std;

int main()
{   
    
    enum row  {A, B};
    
    bool aud[2][2] = { 0,0 };
    
    for(int i=0; i<2; i++){
            for(int j=0; j<2;j++) {
                    cout << aud[i][j] << endl;
            }
    }
    
    int row;
    int seat;
    cout << "Enter your choice of seat-";

    cout << endl << "Row: ";
    cin >> row;
    
    cout << "seat number: ";
    cin >> seat;

    // add a condition to check the status of the seat here
    //-------
    
    //else    
    aud[row][seat] = 1;
    
    for(int i=0; i<2; i++){
            for(int j=0; j<2;j++) {
                    cout << aud[i][j] << endl;
            }
    }
    
    system("pause");
    return 0;
}

A more complex implementation could be done in OO way as -
create each seat as an object
each customer as an object
and having association between the two.

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.