Question: COSC 2 1 5 : Homework # 2 Write a simple airline ticket reservation program. The program should display a menu with the following options:

COSC 215: Homework #2
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 HW2 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 BerdikHW2. Violating this naming convention will result in a two-point
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. SLL.java CLASS public class SLL {
SLLNode head, tail;
void insertAtHead(T t){
if (head == null){
head = new SLLNode(t);
tail = head;
}
else {
SLLNode newHead = new SLLNode(t, head);
head = newHead;
}
}
void insertAtTail(T t){
if (tail == null){
tail = new SLLNode(t);
head = tail;
}
else {
SLLNode newTail = new SLLNode(t);
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 SLLNode(T info, SLLNode next){
this.info = info;
this.next = next;
}
public SLLNode(T info){
this.info = info;
next = null;
}
public SLLNode(){
info = null;
next = null;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!