Question

In: Computer Science

Write a simple airline ticket reservation program. The program should display a menu with the following...

Write a simple airline ticket reservation program. The program should display
a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit on the number of flights. Create a linked list of flights with each node including a pointer to a linked list of passengers.

PLEASE PROVIDE IN PSEUDOCODE, THANK YOU!

Solutions

Expert Solution

This Program can be compared to Linked List Operations.

Reserve A Ticket --> Insertion In a Sorted Linked List of Strings

Cancel a reservation --> Deletion of a particular node in Linked List.

Check whether a ticket is reserved for a particular person --> Searching in Linked List

Display the passengers --> Display A Linked List

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

Creation of Linked List

DECLARE struct Node
Declare string Name
Declare struct Node *next
END DECLARE
DECLARE struct Node*head

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

Insertion In Sorted Linked List

DECLARE reservation()
    //Create a New Node
    struct Node* new_node = new_node();
    name="Enter Name of passenger"
    new_node->name = name
    new_node->next = NULL

    //Declare a Node for traversal
      struct Node* current;
    /* Special case for the head end if the name of passenger is first in ascending order */
    if (head == NULL OR (head->name) >= new_node->name)
        new_node->next = head;
        head = new_node;
    else
        /* Locate the node before the point of insertion */
        current = head;
        while (current->next != NULL AND current->next->name < new_node->name)
            current = current->next;
        END WHILE
        new_node->next = current->next;
        current->next = new_node;
    END IF

PRINT "THANK YOU, YOUR TICKET HAS BEEN RESERVED"
END DECLARE

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

Deletion of a particular node in Linked List.

DECLARE cancellation()
    name="ENTER NAME TO CANCEL RESERVATION"
    // Store head node
    struct Node* temp = *head_ref, *prev;

    // If head node itself holds the name to be deleted
    if (temp != NULL AND temp->name == name)
        head= temp->next;   // Changed head
        delete temp();      // free old head
        return;
    END IF

    // Search for the Name to be Deleted and keep track of the
    // previous node as we need to change 'prev->next'
    while (temp != NULL AND temp->data != name)
        prev = temp;
        temp = temp->next;
    END while

    // If key was not present in linked list
    if (temp == NULL) return;
    END if

    // Unlink the node from linked list
    prev->next = temp->next;

    delete(temp); // Deleting Or Cancel Reservation

PRINT "YOUR RESERVATION HAS BEEN CANCELLED"
END DECLARE

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

Searching in Linked List

DECLARE check()
    name="ENTER NAME OF PASSENGER TO BE SEARCHED"
    struct Node* current = head; // Initialize current
    while (current != NULL)
        IF (current->name == name)
            PRINT "YES,Ticket is Reserved"
        END IF
        current = current->next;
    END while
    PRINT "Sorry, Ticket is Not Reserved"
END DECLARE

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

Display A Linked List

DECLARE display()
     Print "NAME OF PASSENGERs"
    while (node != NULL)
        PRINT( node->name)
        node = node->next;
    END while
END DECLARE

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

MAIN

DECLARE MAIN()
     Print "Hello, WELCOME TO OUR AIRLINES"
     Print "Enter 1 for Ticket Reservation
            Enter 2 for Cancel Reservation
            Enter 3 for Check Your Reservation
            Enter 4 for Passengers Name List
    Initialize choice=-1;
    while(choice!=0)
    choice="ENTER YOUR CHOICE and 0 to exit"
    //Here we can use switch case or if-else
      if(choice=1)
        CAll Function reservation()
      else if(choice=2)
        CAll Function cancellation()
      else if(choice=3)
        CAll Function check()
      else if(choice=4)
        CAll Function display()
      END if
    END while
END DECLARE

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


Related Solutions

I want to write this program in java. Write a simple airline ticket reservation program in...
I want to write this program in java. Write a simple airline ticket reservation program in java.The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit...
Write a program to prompt the user to display the following menu: Sort             Matrix                   Q
Write a program to prompt the user to display the following menu: Sort             Matrix                   Quit If the user selects ‘S’ or ‘s’, then prompt the user to ask how many numbers you wish to read. Then based on that fill out the elements of one dimensional array with integer numbers. Then sort the numbers and print the original and sorted numbers in ascending order side by side. How many numbers: 6 Original numbers:                     Sorted numbers 34                                                                         2          55                                                      ...
Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names     &
Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names             Quit If the user selects Guess-number, your program needs to call a user-defined function called int guess-number ( ). Use random number generator to generate a number between 1 – 100. Prompt the user to guess the generated number and print the following messages. Print the guessed number in main (): Guess a number: 76 96: Too large 10 Too small 70 Close Do you...
C++ PLEASE Write a program to prompt the user to display the following menu: Guess-Number                       ...
C++ PLEASE Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names             Quit If the user selects Guess-number, your program needs to call a user-defined function called int guess-number ( ). Use random number generator to generate a number between 1 – 100. Prompt the user to guess the generated number and print the following messages. Print the guessed number in main (): Guess a number: 76 96: Too large 10 Too small 70 Close...
Write a menu program to have the above options for the polynomials. Your menu program should...
Write a menu program to have the above options for the polynomials. Your menu program should not use global data; data should be allowed to be read in and stored dynamically. Test your output with the data below. Poly #1: {{2, 1/1}, {1, 3/4}, {0, 5/12}} Poly #2: {{4, 1/1}, {2, -3/7}, {1, 4/9}, {0, 2/11}} provide a C code (only C please) that gives the output below: ************************************ *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1....
This is an exercise for a menu-driven program. Program should use shell functions. Write a program...
This is an exercise for a menu-driven program. Program should use shell functions. Write a program that displays the following menu: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a rectangle 3. Calculate the area of a triangle 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for the radius of the circle and then display the area. Use the following formula to calculate the circle’s area: ?...
Write a program that asks the user to enter five test scores. The program should display...
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100...
The program is to be called CarClub The application will display menu as below 1. load...
The program is to be called CarClub The application will display menu as below 1. load cars 2. display all cars 3. search car 4 count cars older the 30 years 5 exit Please enter your option: Load car menu should read input data from text file name (car.txt) Car class have 4 data members which are. Car make, car model, car year and car price In addition If both car year and price were not provided, year has a...
Write a simple menu-driven program called “Million Dollar Game”. The dice that we are using for...
Write a simple menu-driven program called “Million Dollar Game”. The dice that we are using for this game are special oriental dice. Each die has six different patterns. The six possible patterns are: Fish, Shrimp, Crab, Chicken, goldenCoin, Barrel. This game has three dice. In this game, the player can place his or her bet on any die-pattern. The amount of the winning prize is directly proportional to the number of matched dice after the two dice have been tossed...
Java I'm trying to create a program that replicates a theater ticket reservation system. I have...
Java I'm trying to create a program that replicates a theater ticket reservation system. I have a Seat class with members row(integer), seat(character) and ticketType(character). Where a ticket type can be 'A' adult, 'C' child, 'S' senior, or '.' recorded as empty. I have a Node generic class that points to other nodes(members): up, Down. Left, Right. It also has a generic payload. Lastly, I have an Auditorium class which is also generic. its member is a First Node<T>. As...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT