Language is in C I am having really difficulty writing this
Language is in \"C++\"
I am having really difficulty writing this program and codes I have so far are below and price.txt file is basically following by the row.
I know this is a really long program but I really need some help. If you can not do the whole thing I just want to know how to break it down to functions
Thank you so much in advance
#include <iostream>
 #include <iomanip>
 #include <fstream>
 using namespace std;
const int ROWS = 15;
 const int COLUMNS = 20;
 const char EMPTY = \'*\';
 const char FULL = \'#\';
 void initializeArray(char temparray0[ROWS][COLUMNS]);
 void displaySeats(char temparray1[ROWS][COLUMNS]);
 void storePrice(int temparray2[ROWS]);
 int displayMenu();
 void buyTicket(int selection, char temparray3[ROWS][COLUMNS]);
int main(){
 char seatingArray[ROWS][COLUMNS];
 int priceArray[ROWS];
 initializeArray(seatingArray);
 displaySeats(seatingArray);
 storePrice(priceArray);
 int selection = displayMenu();
 buyTicket(selection, seatingArray);
 displaySeats(seatingArray);
   
   
 return 0;
 }
void initializeArray(char temparray0[ROWS][COLUMNS]){
 for(int i=0; i<ROWS; i++){
 for(int j=0; j<COLUMNS; j++){
 temparray0[i][j] = EMPTY;
 }
 }
 }
void displaySeats(char temparray1[ROWS][COLUMNS]){
 cout << \"* Seats available\ \" << \"# Reserved Seats\ \";
 cout << \"Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \"
 << \"16 17 18 19\ \";
 for(int x=0; x<ROWS; x++){
 cout << \"Row\" << setw(3) << right << x;
 for(int y=0; y<COLUMNS; y++){
 cout << setw(3) << right << temparray1[x][y];
 }
 cout << \"\ \";
 }
 }
void storePrice(int temparray2[ROWS]){
 ifstream inputFile;
 int count = 0;
 inputFile.open(\"/Users/semin/desktop/prices.txt\");
 while(count < ROWS && inputFile >> temparray2[count])
 count++;
 inputFile.close();
 }
int displayMenu(){
 int choice;
 cout << endl << \"Menu:\" << endl;
 cout << \"1) Buy ticket\" << endl;
 cout << \"2) Total sell and exit\" << endl << endl;
 cout << \"Enter your choice : \";
 cin >> choice;
 while(choice != 1 && choice != 2){
 cout << \"Invalid choice\" << endl;
 cout << \"Enter your choice : \";
 cin >> choice;
 }
 return choice;
 }
void buyTicket(int selection, char temparray3[ROWS][COLUMNS]){
 int temprow;
 int tempcolumns;
 if(selection == 1){
 cout << endl << \"Enter row: \";
 cin >> temprow;
 cout << \"Enter seat: \";
 cin >> tempcolumns;
 else if(selection == FULL){
 cout << \"Invalid seat choice\";
 }
 }
 temparray3[temprow][tempcolumns] = FULL;
 }
Solution
#include <iostream>
 #include <iomanip>
 #include <fstream>
 using namespace std;
 const int ROWS = 15;
 const int COLUMNS = 20;
 const char EMPTY = \'*\';
 const char FULL = \'#\';
 void initializeArray(char temparray0[ROWS][COLUMNS]);
 void displaySeats(char temparray1[ROWS][COLUMNS]);
 void storePrice(int temparray2[ROWS]);
 int displayMenu();
 void buyTicket(int selection, char temparray3[ROWS][COLUMNS]);
 int tickets_sold=0, total_revenue=0;
 char seatingArray[ROWS][COLUMNS];
 int priceArray[ROWS];
int main(){
 
 initializeArray(seatingArray);
 displaySeats(seatingArray);
 storePrice(priceArray);
    int choice;
    do
    {
        int selection = displayMenu();
        buyTicket(selection, seatingArray);
 //displaySeats(seatingArray);
        displaySeats(seatingArray);
        cout<<\"Press any key to continue other than 0, 0 to quit \"<<endl;
        cin>>choice;
    }while(choice!=0);
 return 0;
 }
 void initializeArray(char temparray0[ROWS][COLUMNS]){
 for(int i=0; i<ROWS; i++){
 for(int j=0; j<COLUMNS; j++){
 temparray0[i][j] = EMPTY;
 }
 }
 }
 void displaySeats(char temparray1[ROWS][COLUMNS]){
 cout << \"* Seats available\ \" << \"# Reserved Seats\ \";
 cout << \"Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \"
 << \"16 17 18 19\ \";
 for(int x=0; x<ROWS; x++){
 cout << \"Row\" << setw(3) << right << x;
 for(int y=0; y<COLUMNS; y++){
 cout << setw(3) << right << temparray1[x][y];
 }
 cout << \"\ \";
 }
 }
 void storePrice(int temparray2[ROWS]){
 ifstream inputFile;
 int count = 0;
 inputFile.open(\"C:\\\\Users\\\\Admin\\\\Desktop\\\\Chegg\\\\programs\\\\Programs\\\\Programs\\\\prices.dat\");
  while(count < ROWS && inputFile >> temparray2[count])
 count++;
 inputFile.close();
 }
 int displayMenu(){
 int choice;
 cout << endl << \"Menu:\" << endl;
 cout << \"1) Buy ticket\" << endl;
 cout << \"2) Total sell and exit\" << endl << endl;
 cout << \"Enter your choice : \";
 cin >> choice;
 while(choice != 1 && choice != 2){
 cout << \"Invalid choice\" << endl;
 cout << \"Enter your choice : \";
 cin >> choice;
 }
 return choice;
 }
 void buyTicket(int selection, char temparray3[ROWS][COLUMNS]){
 int temprow;
 int tempcolumns;
   
 if(selection == 1){
 cout << endl << \"Enter row: \";
 cin >> temprow;
 cout << \"Enter seat: \";
 cin >> tempcolumns;
        if(temparray3[temprow][tempcolumns] == EMPTY)
        {
            temparray3[temprow][tempcolumns] = FULL;
            total_revenue+=priceArray[temprow];
            tickets_sold++;
            return;
        }
        if(temparray3[temprow][tempcolumns] == FULL)
        {
            cout<<\"Ticket is not available\"<<endl;
            cout<<\"Choose another seat ..\"<<endl;
            return;
        }
       
       
    }
    if( selection == 2)
    {
        cout<<\"updated seating chart and display \"<<endl;
        displaySeats(seatingArray);
        cout<<\"Total Tickets Sold: \"<<tickets_sold<<endl;
        cout<<\"Total Revenue: $\"<<total_revenue<<endl;
        return;
    }
   
   
 }




