Question

C++ Help please- kind of long. The aim is to implement a seat reservation system for...

C++ Help please- kind of long.

The aim is to implement a seat reservation system for a passenger airplane. We assume a small airplane with 10 rows and 4 seats per row. We assume that the seat chart is initially stored in a file “chartIn.txt” in the following format:

1   A B C D

2   A B C D

3   A B C D

4   A B C D

5   A B C D

6   A B C D

7   A B C D

8   A B C D

9   A B C D

10 A B C D

The example given above means that seats 1A, 1B, 1C, 1D, 2A, 2B, 2C, 2D, 3A, … are all available. Note that the number 1, 2, 3 … also belong to the file.   Below is another example of data stored in the file “chartIn.txt”:

1   A X C D

2   A B C D

3   A B C D

4   A B C D

5   A X C D

6   A B C D

7   A B C D

8   A B C D

9   A B X D

10 A X X D

This second example demonstrates that the following seats marked with ‘X’ are reserved: 1B, 5B, 9C, 10B, 10C.

The program must use a function to initially read the seat chart from the file “chartIn.txt” and fill out a 2-dimentional array called seatChart. The main program then calls a function to display the following menu:

------------------------ Menu ---------------------------

1. Display Seat Chart

2. Reserve Seat

3. Cancel Reservation

4. Quit

----------------------------------------------------- ---

Please Enter Your Choice (1-4):

Below is a description of each option in the menu:

  • Option 1 (Display Seat Chart): The program calls a function that displays the seat chart from the array seatChart using the format shown in page 1.
  • Option 2 (Reserve Seat): The program calls a function that prompts users for the seat desired as a string (e.g., 3A, 7D, etc.) and then determines the row number and column number of the array element that needs to be accessed. If the seat is available, it reserves it by assigning ‘X’ to the seat and displays a message stating that the seat was reserved. Otherwise it displays a message stating that the seat is not available.
  • Option 3 (Cancel Reservation): The program calls a function that prompts users for the seat to be canceled as a string (e.g., 3A, 7D, etc.) and then determines the row number and column number of the array element that needs to be accessed. If the seat is available, the program displays an error message stating that the seat to be canceled has not been initially reserved. Otherwise it makes the seat available and displays a message stating that the seat reservation has been cancelled.
  • Option 4 (Quit): The program displays a thank you message and terminates.

Component 1:   Software System Design

Use the function decomposition method to describe all functions that you will implement in this project. Use arrow lines to indicate the relationship among all functions, and their calling sequence.

Component 2:   Software Documentation

Precede each function with the following standard information:

//   Purpose: …

//   Author: ….

//   Creation Date: …

//   Last Modification Date: …

Also, include a comment at the beginning of the entire program with the following information:

//   Purpose: …

//   Author: ….

//   Creation Date: …

//   Last Modification Date: …

Component 3: Program Extension

Extend your program to process airplanes of any size (any number of rows and columns).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream.h>
char seat[10][4]; //creating a array for seats

//function to display seat details
void displaySeat()
{
   for(int i=0;i<10;i++)
   {
       cout<<"\n"<<i+1<<" ";
       for(int j=0;j<4;j++)
       {
           cout<<seat[i][j]<<" ";
       }
   }
}

//function to reserve seat
void reserveSeat()
{
   char s[4];
   cout<<"\nEnter the desired seat:";
   cin>>s;
   int i,n,r;
   int c;
   i=n=0;
   while(s[i]!='\0')
   {
       n++;
       i++;
   }
   if(n==3)
   {
       r=9;
       c=s[2]-65;
   }
   else
   {
       r=s[0]-61;
       c=s[1]-65;
   }
   if(seat[r][c]=='X')
   {
       cout<<"\nThe seat is already reserved!";
   }
   else
   {
       seat[r][c]='X';
       cout<<"\nThe seat has been reserved successfully!";
   }
}

//function to cancel ticket
void cancel()
{
   char s[4];
   cout<<"\nEnter the seat to cancel:";
   cin>>s;
   int i,n,r;
   int c;
   i=n=0;
   while(s[i]!='\0')
   {
       n++;
       i++;
   }
   if(n==3)
   {
       r=9;
       c=s[2]-65;
   }
   else
   {
       r=s[0]-61;
       c=s[1]-65;
   }
   if(seat[r][c]=='X')
   {
       seat[r][c]=65-c;
       cout<<"\nThe seat is cancelled successfully!";
   }
   else
   {
       cout<<"\nThe seat is not yet reserved to cancel!";
   }
}
void main()
{
  
   for(int i=0;i<10;i++)
   {
       seat[i][0]='A';
       seat[i][1]='B';
       seat[i][2]='C';
       seat[i][3]='D';
   }
   int ch;
   do{
       cout<<"\n-------------Menu------------";
       cout<<"\n1. Display Seat Chart\n2. Reserve Seat\n3. Cancel reservation\n4. Quit";
       cout<<"\n-----------------------------";
       cout<<"\nPlease Enter your Choice(1-4):";
       cin>>ch;
       switch(ch)
       {
           case 1:
               displaySeat();
          
           break;
           case 2:
               reserveSeat();
           break;
           case 3:
               cancel();
           break;
           case 4:
               cout<<"\nThank You!";
           break;
           default:
               cout<<"\nInvalid Choice";
           break;
       }
   }while(ch!=4);
}

Add a comment
Know the answer?
Add Answer to:
C++ Help please- kind of long. The aim is to implement a seat reservation system for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is...

    A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Implement a well-structured C program to enable a user to make and cancel seat reservations for the bus. The program uses a text-file seats.txt to store the reservation...

  • Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating...

    Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 1 2 3 21 22 23 24 25 Implement a well-structured Java program to enable a user to make and cancel seat reservations for the bus. The program uses Array to store the reservation information: 0...

  • Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating...

    Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating pattern: A         1          2          3          4          5          6          7          8          9          ……    100 B         1          2          3          4          5          6          7          8          9          ……    100 AISLE C         1          2          3          4          5          6          7          8          9          ……    100 D         1          2          3          4          5          6          7          8          9          ……    100 Either use 2D STL array (array that contains array) or 4 single dimensional STL arrays of size 100. Write a program to display a menu to the user with the options to reserve a seat of choice, reserve a window seat, reserve an aile seat, reserve a seat (any available), withdraw reservation, update reservation (change seat) and display...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • The language is C++ for visual studio express 2013 for windows create a TicketManager class and...

    The language is C++ for visual studio express 2013 for windows create a TicketManager class and a program that uses the class to sell tickets for a performance at a theater. Here are all the specs. This is an intense program, please follow all instructions carefully. -I am only creating the client program that uses the class and all it's functions -The client program is a menu-driven program that provides the user with box office options for a theater and...

  • Can you help us!! Thank you! C++ Write a program that can be used by a...

    Can you help us!! Thank you! C++ Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...

  • P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:...

    P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30...

  • Hi I need help with a java program that I need to create a Airline Reservation...

    Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...

  • The Course Project can be started in Week 7 and is due by 11:59 pm CT...

    The Course Project can be started in Week 7 and is due by 11:59 pm CT Saturday of Week 8. It must follow standard code formatting and have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does. Pseudocode must be provided in the comment block at the top of the file. This program will allow the...

  • Write pseudocode for a program where the seating map for a particular performance at a theater...

    Write pseudocode for a program where the seating map for a particular performance at a theater contains 70 rows of 100 seats each. Using an array where applicable, develop the pseudeocode for a program that allows a user to continuously enter each household size and then a) Allows a user to continuously enter a row number and seat number until they enter an appropriate sentinel value for the row number in order to stop entering input. Each time the user...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT