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

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 operations: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a 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...
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 java program that will first display the following menu: Choose one of the following...
Write a java program that will first display the following menu: Choose one of the following 1- To add 2 double integers 2- To add 2 integer numbers 3- To add 3 double numbers 4- To add 3 integer numbers After reading user’s choice, use a switch case statement to call the corresponding method Void add 1 (double n1, double n2) Void add2() Double add3 (double n1, double n2, double n3) Double add4 ()
Write a C++ program to run a menu driven program with the following choices: 1) Display...
Write a C++ program to run a menu driven program with the following choices: 1) Display the grades 2) Adjust grade 3) Display Average for each student 4) Display number of student with at least a B 5) Quit requirements: 1. Write a function called getValidGrade that allows a user to enter in an integer and loops until a valid number that is >= 0 and <= 100 is entered. It returns the valid value. 2. Write a function called...
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: 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 python program to display a menu with the following options: (1) add, (2) subtract,...
Write a python program to display a menu with the following options: (1) add, (2) subtract, (3) multiply, (4) divide (5) mod, and (6) do nothing. I f the user enters something else (except 1-6), the program should display an error message. Otherwise, it should ask the user for two numbers, perform the calculation, and display the result.
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....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT