Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use C++ to write the codes. Thanks! Question 1 This question is based on

ID: 3724557 • Letter: P

Question

Please use C++ to write the codes. Thanks!

Question 1 This question is based on contents covered in Chapter 10 of text. The objectives of the . access if students have understood the basic concepts of object-oriented class write the class specification, constructor and methods write test driver to test the written methods . Examine the following class diagram, additional information and answer the following date: string llevent date in YYYYMMDD format event Type: char I-intermal, P public ticketClass: char I/S-standard, V-vip getEventN getDatc0:string isMember0:bool TICKETO Constructor with default values eventName "unknown" date "unknown eventType T ticketClass s' price -o; membertrue Assessor for data date and memberisMember returns true if member is true Prompt the user to enter the eventName, date, event Type, ticketClass, price and member, Only date in current year (2018) is valid. For publie events add S10 to price. VIP tickcts are three times the valuc of standard tickets (after adding $10 is sellTicketO:void on the final price. Calculate the price and store it in member variable price Uses cout to display the respective data members. If member is true, displays "This purchase is made by Member If member is faise, displays "This purchase is (a) Develop C++ code to implement the TICKET specification (b) Develop C+ code to implement ALL methods found in the TICKET class. (c) Write a function, displayMenu that display the following menu. Function signature: int displayMerue). The function accepts, validates the input and returns the valid choice to the ealling program ickets Sales System Display a11 tickets Display tickets sold to Menbers for a given Event name Display tickets in decending order of the event date nter choice to 5) (d) Write a test driver to test and fulfil at lcast the following requirements (i) (ii) Calls the function, displayMenel) in a loop and invokes the respective methods of iii) Option 1: invoke the mcthod, sellTicket ) and performs boundary check for the (iv) Option 2: uses a loop to invoke the display method ofarray of TV objeets Declares an array of 10 TICKET objects. TV class corresponding to the selected choice array of TICKET objects Option 3: inputs a eventName from user and traverses the array of TICKET objects to display the tickets of a event purchased by members. (v) (vi) Option 4: makes a copy of array of TICKET objects. Sorts the new array in descending order (reverse chronological order) of date. Uses a loop to invoke the display method of sorted array of TICKET objects. [Note:- Write you own sorting algorithm instead of using functions like std:sorto]. (vii) Option S: displays the message,"Thank you for using the program..." and exit the Include a screen output in your submission. (15 marks)

Explanation / Answer

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

void get_menu_choice(char &MenuChoice);

void sell_seat(char& tickets[][3][20]);

void print_day_list(char &tickets[][3][20]);

void print_floor_list(char& tickets[][3][20]);

void print_chart(float &seats[rows][columns])

const char FULL ='*';

const char EMPTY = '-';

const int rows = 3;

const int columns = 20;

const int days = 3;

int main()

{

char MenuChoice ;

char tickets[3][3][20];

get_menu_choice(MenuChoice);

print_chart(seats);

sell_seat(tickets);

print_day_list(tickets);

print_floor_list(tickets);

char choice;

cout<<" Enter the choice ";

cin>>choice ;

choice = toupper ( choice ) ;

do

{

switch(choice)

{

case 'S':

cout << "S - Sell a Ticket.";

sell_seat(tickets);

break;

case 'C':

cout << "C - Display Seating Chart.";

print_chart(seats);

break;

case 'D':

cout << "D - Display Sales Summary - Day Listing";

print_day_list(tickets);

break;

case 'F':

cout << "F - Display Sale Summary - Floor Listing";

print_floor_list(tickets);

break;

case 'Q':

cout << "Quit";

break;

default:

cout << "Invalid choice. Try again!" << endl;

break;

}

}while(choice != 'Q');

cin.clear();

cin.sync();

return 0;

}

void get_menu_choice(char &MenuChoice)

{

cout << " *** Main Menu *** " << endl;

cout << "S - Sell a Ticket." << endl;

cout << "C - Display Seating Chart." << endl;

cout << "D - Display Sales Summary - Day Listing" << endl;

cout << "F - Display Sale Summary - Floor Listing" << endl;

cout << "Q - Quit" << endl;

cout << "Your Choice: ";

cin >> MenuChoice;

}

void sell_seat(char& tickets[][3][20])

{

char choice, level;

int day, location;

cout << "Enter seat request by day (T)hursday, (F)riday, (S)aturday" << endl;

cout << "followed by Section (F)loor, (B)alcony, (U)pper Balcony" << endl;

cout << "followed by seat number (1-20)." << endl;

do{

cin >> choice ;

choice = toupper(choice);

switch( choice )

{

case 'T':

day = 0;

break;

case 'F':

day = 1;

break;

case 'S':

day = 2;

break;

default:

cout<<"Invalid choice try again";

}

} while( choice != 'T' || choice != 'F' || choice != 'S' ) ;

do{

cin >> level ;

level = toupper(level);

switch( level )

{

case 'F':

location = 0;

break;

case 'B':

location = 1;

break;

case 'U':

location = 2;

break;

default:

cout<<"Invalid choice try again";

}

} while( choice != 'F' || choice != 'B' || choice != 'U' ) ;

int Count = 0;

for (Count = 0; Count < 20; Count++)

{

if (tickets[day][location][Count] == '*')

{

tickets[day][location][Count] = 'S';

break;

}

}

if( Count == 20 )

{

cout << " All seats filled for " ;

}else

{

cout<<" Seat booked at "<< day << " location " << location <<"count "<<Count;

}

}

void print_chart(float &seats[rows][columns])

{

for(int y = 0; y < rows; y++)

{

for(int x = 0; x < columns; x++)

if(seats[y][x] == 0.00)

{

cout << "-";

}

else

{

cout << "*";

}

}

cout << endl;

}

void print_day_list(const char &tickets[][3][20])

{

string dayTitles[3] = {"Thursday ", "Friday ", "Saturday "};

string locationTitles[3] = {"Floor ", " Balcony ", " Upper Balcony "};

int totalSold = 0, dayTotal[3] = {0}, locationTotal[3] = {0}, sold = 0, dayAmount[3] = {0};

int amount[3] = {0};

int price[3] = {30, 20, 10};

for (int day = 0; day < 3; day ++)

{

cout << dayTitles[day] << endl;

for (int location = 0; location < 3; location++)

{

cout << locationTitles[location];

sold = 0;

for (int seats = 0; seats < 20; seats++)

{

if(tickets[day][location][seats] == 'S')

{

sold++;

totalSold++;

dayTotal[day]++;

locationTotal[location]++;

dayAmount[day] += price[location];

}

}

cout << ' ' <<"Tickets sold " << sold << " $" << sold * price[location] << endl;

amount[location] += sold * price[location];

}

}

cout << " Total tickets sold for all concerts " << totalSold

<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;

}

void print_floor_list(char tickets[][3][20])

{

string locationTitles[3] = {"Floor ", "Balcony ", "Upper Balcony "};

string dayTitles[3] = {"Thursday ", " Friday ", " Saturday "};

int totalSold = 0, locationTotal[3] = {0}, dayTotal[3] = {0}, sold, locationAmount[3] = {0};

int amount[3] = {0};

int price[3] = {30, 20, 10};

for (int location = 0; location < 3; location++)

{

cout << locationTitles[location] << endl;

for (int day = 0; day < 3; day++)

{

cout << dayTitles[day];

sold = 0;

for (int seats = 0; seats < 20; seats++)

{

if(tickets[location][day][seats] == 'S')

{

sold++;

totalSold++;

locationTotal[location]++;

dayTotal[day]++;

locationAmount[location] += price[day];

}

}

cout << ' ' <<"Tickets sold " << sold << " $" << sold * price[day] << endl;

amount[day] += sold * price[day];

}

}

cout << " Total ticket sales for all shows: " << totalSold

<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;

}