Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COSC 2 1 5 : Homework # 2 Write a simple airline ticket reservation program. The program should display a menu with the following options:
COSC : Homework #
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, display the passengers, and exit the program. The information should be
maintained on an alphabetized linked list of names that uses the Linked List implementation that we wrote together in class.
Although you are permitted to include additional classes as you see fit, you must at minimum create a class named HW where is your last name and use this as the class in which you write your main method. For example, if I were doing this assignment, my
class be named BerdikHW Violating this naming convention will result in a twopoint
deduction from your grade.
Your work must be submitted on Canvas by the specified due date. Since your submissions will
be tested using the LinkedList implementation that we wrote together, you should not modify it
and there is no need for you to include it in your Canvas submission. SLLjava CLASS public class SLL
SLLNode head, tail;
void insertAtHeadT t
if head null
head new SLLNodet;
tail head;
else
SLLNode newHead new SLLNodet head;
head newHead;
void insertAtTailT t
if tail null
tail new SLLNodet;
head tail;
else
SLLNode newTail new SLLNodet;
tail.next newTail;
tail newTail;
T deleteFromHead
if head null If this list is empty
return null;
T headInfo head.info;
head head.next;
if head null
tail null;
return headInfo;
T deleteFromTail
if tail null If the list is empty
return null;
T tailInfo tail.info;
if head tail If the list only has one node
head null;
tail null;
return tailInfo;
SLLNode newTail null;
for SLLNode node head; node.next null; node node.next
newTail node;
newTail.next null;
tail newTail;
return tailInfo;
SLLNode.java class public class SLLNode
T info;
SLLNode next;
public SLLNodeT info, SLLNode next
this.info info;
this.next next;
public SLLNodeT info
this.info info;
next null;
public SLLNode
info null;
next null;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started