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 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 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 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....
C++ Write a menu based program for the pet rescue. There should be 2 menu options...
C++ Write a menu based program for the pet rescue. There should be 2 menu options -Add a pet -View pets -If the user chooses option 1, you will open a data file for writing without erasing the current contents, and write a new pet record to it. The file can be formatted any way that you choose but should include the pet's name, species, breed, and color. You my also include any additional information you think is appropriate. -If...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT