Pls use C++ to answer thank you! Pls use C++ to answer thank you! Pls use C++ to answer thank you!

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Pls use C++ to answer thank you! Pls use C++ to answer thank you! Pls use C++ to answer thank you!

Post by answerhappygod »

Pls use C++ to answer thank you! Pls use C++ toanswer thank you! Pls use C++ to answer thankyou!
Pls Use C To Answer Thank You Pls Use C To Answer Thank You Pls Use C To Answer Thank You 1
Pls Use C To Answer Thank You Pls Use C To Answer Thank You Pls Use C To Answer Thank You 1 (55.18 KiB) Viewed 36 times
Pls Use C To Answer Thank You Pls Use C To Answer Thank You Pls Use C To Answer Thank You 2
Pls Use C To Answer Thank You Pls Use C To Answer Thank You Pls Use C To Answer Thank You 2 (53.98 KiB) Viewed 36 times
Question C2 The program below simulates a seat reservation system of a theatre. At first, all the seats in the theatre are empty (marked with .'). Seats can be chosen based on user's input or automatically by the system. Reserved seats are marked with 'X' in the seating plan. Each time only consecutive seats along the same row will be reserved. #include #include using namespace std; const int ROW = 5; const int COL = 8; void init (char seats [ROW] [COL]) { for (int i = 0; i < ROW; i++) } void print (char seats [ROW] [COL], int vacancy) { cout << "Vacant Seats: " << vacancy << endl; cout << "Seating Plan:" << endl; // Your codes for C2 (a) should be inserted here } void getInput (int &r, int &c, int &num) { } for (int j = 0; j < COL; j++) seats[j] = !. '; } bool enough (char seats [ROW] [COL], int r, int c, int num) { // Your codes for C2 (c) should be inserted here char input [5]; // stores input seat number cout << "Reservation\n"; cout << "_ ---------\n"; // Your codes for C2 (b) should be inserted here void mark (char seats [ROW] [COL], int r, int c, int num) { // Your codes for C2 (d) should be inserted here } } bool autoSelect (char seats [ROW] [COL], int &r, int &c, int num) for (r = 0; r < ROW; r++) { for (c=0; c < COL; C++) if (enough (seats, r, c, num)) return true; return false;
int main() { int row, col, num; bool hasSeats = false; int vacancy=ROW COL; char seat Plan [ROW] [COL]; init (seat Plan); do { A B C D print (seat Plan, vacancy); get Input (row, col, num); E if (row == -1 && col == -1) else hasSeats autoSelect (seat Plan, row, col, num); hasSeats w enough (seat Plan, row, col, num); if (hasSeats) mark (seat Plan, row, col, num); vacancy = num; cout << "Seats are reserved.\n\n"; hasSeats = false; else { cout << "Not enough seats.\n\n"; } while (vacancy > 0); The sample output below will be shown when all parts are completed correctly. Approriate use of loop structure and constant variables are expected in your answers. cout << "Thanks for using. Good-bye!" << endl; return 0; Sample Output: (the vertical display is shown in row format due to space concern) Vacant Seats: 40 Seating Plan: Vacant Seats: 35 Seating Plan: 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 X X X X X. Reservation How many seats? 5 Seat number: A2 Seats are reserved. A B C D E. + Reservation How many seats? 4 Seat number: A0 Not enough seats. Vacant Seats: 35 Seating Plan: 0 1 2 3 4 5 6 7 X X X X X. A B C E Reservation How many seats? 4 Seat number: BO Seats are reserved.
Question C2 (continued) Vacant Seats: 31 Seating Plan: 0 1 2 3 4 5 6 7 X X X X X A BX X X X C. D E Reservation How many seats? 3 Seat number: C3 Seats are reserved. Vacant Seats: 28 Seating Plan: 0 1 2 3 4 5 6 7 A.. X X X X X. BX X X X C. X X X D E . Reservation How many seats? 3. Seat number: AUTO Seats are reserved. Vacant Seats: 25 Seating Plan: (...to be answered in C2(e)...) (a) Complete the print() function that prints the seating plan, based on the format of the given sample output above. (5 marks) (b) Complete the getInput() function that gets the user input of number of seats (store in parameter num), and seat number (e.g., A0 using the given array input). Based on the input seat number, it then determines the row and column number (store in parameters and c) accordingly. If user inputs "AUTO" as seat number, the function sets both row and column. number to -1. Note that row 'A' corresponds to row 0 in the seats array. You may assume that user always inputs correctly. (5 marks)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply