SlideShare a Scribd company logo
For the following questions, you will implement the data structure to store information used by a
local car dealer. Each car has some information and stored in a text files called cars: Write a
main program for all questions to let the user enter, delete, search for information, and print
current cars stored in the data structure. Cars formatted so car records separated by a blank line.
Each record contains (in order, each in a single line): Make (manufacturer). Model, Year,
Mileage, Price. Implement a double linked-list to store cars data. Write a double linked-list class
including search, delete, append (to the head and tail), and remove (from the head and tail).
Implement a FIFO queue of car data using the double linked-list. You can use the double linked
list you wrote in Q1. Implement a max-heap of cars data that can extract the car with the highest
price. Write a max-heap class including heapify, build heap, extract, and insertion. Implement a
binary search tree of car data. Write a BST class including search, insertion, and deletion.
Solution
Cars.java
package pacages;
public class Cars {
String make;
String model;
int year;
double mileage;
double price;
// Setters and getters for the Cars member variables
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public double getMileage() {
return mileage;
}
public void setMileage(double mileage) {
this.mileage = mileage;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String toString()
{
return "Make: "+getMake()+ " Model: "+getModel()+ " Year: "+getYear() + "
Mileage: "+getMileage() + " Price: "+getPrice();
}
}
DoublyLinkedList.java
package pacages;
class Node
{
protected Cars data;
protected Node next, prev;
/* Constructor */
public Node()
{
next = null;
prev = null;
data = null;
}
/* Constructor */
public Node(Cars d, Node n, Node p)
{
data = d;
next = n;
prev = p;
}
/* Function to set link to next node */
public void setLinkNext(Node n)
{
next = n;
}
/* Function to set link to previous node */
public void setLinkPrev(Node p)
{
prev = p;
}
/* Funtion to get link to next node */
public Node getLinkNext()
{
return next;
}
/* Function to get link to previous node */
public Node getLinkPrev()
{
return prev;
}
/* Function to set data to node */
public void setData(Cars d)
{
data = d;
}
/* Function to get data from node */
public Cars getData()
{
return data;
}
}
/* Class linkedList */
public class DoublyLinkedList
{
protected Node start;
protected Node end ;
public int size;
/* Constructor */
public DoublyLinkedList()
{
start = null;
end = null;
size = 0;
}
/* Function to check if list is empty */
public boolean isEmpty()
{
return start == null;
}
/* Function to get size of list */
public int getSize()
{
return size;
}
/* Function to insert element at begining */
public void appendAtHead(Cars val)
{
Node nptr = new Node(val, null, null);
if(start == null)
{
start = nptr;
end = start;
}
else
{
start.setLinkPrev(nptr);
nptr.setLinkNext(start);
start = nptr;
}
size++;
}
/* Function to insert element at end */
public void appendAtTail(Cars val)
{
Node nptr = new Node(val, null, null);
if(start == null)
{
start = nptr;
end = start;
}
else
{
nptr.setLinkPrev(end);
end.setLinkNext(nptr);
end = nptr;
}
size++;
}
/* Function to remove element at end */
public void deleteAtTail()
{
end = end.getLinkPrev();
end.setLinkNext(null);
size-- ;
}
public void deleteAtHead()
{
start = start.getLinkNext();
start.setLinkPrev(null);
size--;
}
/* Function to display the list */
public void display()
{
if (size == 0)
{
System.out.print("empty ");
return;
}
if (start.getLinkNext() == null)
{
System.out.println(start.getData() );
return;
}
Node ptr = start;
System.out.print(start.getData()+ " ");
ptr = start.getLinkNext();
while (ptr.getLinkNext() != null)
{
System.out.print(ptr.getData()+ " ");
ptr = ptr.getLinkNext();
}
System.out.print(ptr.getData()+ "  ");
}
}
MaxHeap.java
package pacages;
public class MaxHeap
{
private Cars[] Heap;
private int size;
private int maxsize;
private static final int FRONT = 1;
public MaxHeap(int maxsize)
{
this.maxsize = maxsize;
this.size = 0;
Heap = new Cars[this.maxsize + 1];
Heap[0] = null;
}
private int parent(int pos)
{
return pos / 2;
}
private int leftChild(int pos)
{
return (2 * pos);
}
private int rightChild(int pos)
{
return (2 * pos) + 1;
}
private boolean isLeaf(int pos)
{
if (pos >= (size / 2) && pos <= size)
{
return true;
}
return false;
}
private void swap(int fpos,int spos)
{
Cars tmp;
tmp = Heap[fpos];
Heap[fpos] = Heap[spos];
Heap[spos] = tmp;
}
private void maxHeapify(int pos)
{
if (!isLeaf(pos))
{
if ( Heap[pos].getPrice() < Heap[leftChild(pos)].getPrice() || Heap[pos].getPrice() <
Heap[rightChild(pos)].getPrice())
{
if (Heap[leftChild(pos)].getPrice() > Heap[rightChild(pos)].getPrice())
{
swap(pos, leftChild(pos));
maxHeapify(leftChild(pos));
}else
{
swap(pos, rightChild(pos));
maxHeapify(rightChild(pos));
}
}
}
}
public void insertion(Cars car)
{
Heap[++size] = car;
int current = size-1;
if(size>2)
{
while(Heap[current].getPrice() > Heap[parent(current)].getPrice())
{
swap(current,parent(current));
current = parent(current);
}
}
}
public void maxHeap()
{
for (int pos = (size / 2); pos >= 1; pos--)
{
maxHeapify(pos);
}
}
public Cars extraction()
{
Cars popped = Heap[FRONT];
Heap[FRONT] = Heap[size--];
maxHeapify(FRONT);
return popped;
}
public void print()
{
for (int i = 1; i <= size / 2; i++ )
{
System.out.print(" PARENT : " + Heap[i] + " LEFT CHILD : " + Heap[2*i]
+ " RIGHT CHILD :" + Heap[2 * i + 1]);
System.out.println();
}
}
}
BST.java
package pacages;
public class BST {
Node root;
// Constructor
BST() {
root = null;
}
public Node search(Node root, Cars car)
{
// Base Cases: root is null or key is present at root
if (root==null || root.data.getMake().equals(car.getMake()))
{
if(root.data.getModel().equals(car.getModel()))
{
if(root.data.getYear() == car.getYear())
{
if(root.data.getMileage() == car.getMileage())
{
if(root.data.getPrice() == car.getPrice())
{
return root;
}
}
}
}
}
// val is greater than root's key
if (root.data.getPrice() > car.getPrice())
return search(root.prev, car);
// val is less than root's key
return search(root.next, car);
}
Node insert(Node root, Cars car) {
/* If the tree is empty, return a new node */
if (root == null) {
root = new Node(car, null, null);
return root;
}
/* Otherwise, recur down the tree */
if (car.getPrice() < root.data.getPrice())
root.prev = insert(root.prev, car);
else if (car.getPrice() > root.data.getPrice())
root.next = insert(root.next, car);
/* return the (unchanged) node pointer */
return root;
}
}
MyClass.java
package pacages;
import java.util.Scanner;
public class MyClass {
static DoublyLinkedList list = new DoublyLinkedList();
static MaxHeap heap = new MaxHeap(100);
static Scanner sc = new Scanner(System.in);
public static void main(String args[])
{
String choice = "y";
int menuChoice = 0;
do
{
System.out.println("MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first
Car data 4. Display all Cars 5. Exit");
menuChoice = sc.nextInt();
switch(menuChoice)
{
case 1: getCarDetails();
break;
case 2: list.deleteAtTail();
break;
case 3: list.deleteAtHead();
heap.extraction();
break;
case 4: list.display();
}
System.out.println("Do you wish to continue? y or n");
choice = sc.next();
}while(choice.equals("y") || choice.equals("Y"));
}
public static void getCarDetails(){
Cars car = new Cars();
System.out.println("Enter Make: ");
car.setMake(sc.next());
System.out.println("Enter Model: ");
car.setModel(sc.next());
System.out.println("Enter Year: ");
car.setYear(sc.nextInt());
System.out.println("Enter Mileage: ");
car.setMileage(sc.nextDouble());
System.out.println("Enter Price: ");
car.setPrice(sc.nextDouble());
list.appendAtTail(car);
heap.insertion(car);
}
}
OUTPUT:
MENU
1. Enter car Details
2. Delete Last car Data
3. Delete first Car data
4. Display all Cars
5. Exit
1
Enter Make:
Hyundai
Enter Model:
324rtf
Enter Year:
2011
Enter Mileage:
30.0
Enter Price:
945677
Do you wish to continue? y or n
y
MENU
1. Enter car Details
2. Delete Last car Data
3. Delete first Car data
4. Display all Cars
5. Exit
1
Enter Make:
Toyota
Enter Model:
375jdg
Enter Year:
2005
Enter Mileage:
25.0
Enter Price:
673522
Do you wish to continue? y or n
y
MENU
1. Enter car Details
2. Delete Last car Data
3. Delete first Car data
4. Display all Cars
5. Exit
4
Make: Hyundai Model: 324rtf Year: 2011 Mileage: 30.0 Price: 945677.0
Make: Toyota Model: 375jdg Year: 2005 Mileage: 25.0 Price: 673522.0
Do you wish to continue? y or n
y
MENU
1. Enter car Details
2. Delete Last car Data
3. Delete first Car data
4. Display all Cars
5. Exit
2
Do you wish to continue? y or n
y
MENU
1. Enter car Details
2. Delete Last car Data
3. Delete first Car data
4. Display all Cars
5. Exit
4
Make: Hyundai Model: 324rtf Year: 2011 Mileage: 30.0 Price: 945677.0
Do you wish to continue? y or n
n

More Related Content

Similar to For the following questions, you will implement the data structure to.pdf

29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript
.NET User Group Rhein-Neckar
 
I need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfI need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdf
aggarwalshoppe14
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfThis is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
bharatchawla141
 
In C#, visual studio, I want no more text boxes added, I have button.pdf
In C#, visual studio, I want no more text boxes added, I have button.pdfIn C#, visual studio, I want no more text boxes added, I have button.pdf
In C#, visual studio, I want no more text boxes added, I have button.pdf
aggarwalenterprisesf
 
The C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptxThe C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptx
VitsRangannavar
 
Oop in java script
Oop in java scriptOop in java script
Oop in java script
Pierre Spring
 
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfCountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
Aggarwalelectronic18
 
C# Programming Help
C# Programming HelpC# Programming Help
C# Programming Help
Programming Homeworks Help
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
arsmobiles
 
Wien15 java8
Wien15 java8Wien15 java8
Wien15 java8
Jaanus Pöial
 
(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
탑크리에듀(구로디지털단지역3번출구 2분거리)
 
COMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdfCOMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdf
fazalenterprises
 
FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf
FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdfFedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf
FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf
alukkasprince
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
eyebolloptics
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
vinodagrawal6699
 
Simple array Java code.The “Park-a-lot” parking garage currently o.pdf
Simple array Java code.The “Park-a-lot” parking garage currently o.pdfSimple array Java code.The “Park-a-lot” parking garage currently o.pdf
Simple array Java code.The “Park-a-lot” parking garage currently o.pdf
fasttracktreding
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app example
Alexey Frolov
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
armitageclaire49
 
Creating an Uber Clone - Part XXVI - Transcript.pdf
Creating an Uber Clone - Part XXVI - Transcript.pdfCreating an Uber Clone - Part XXVI - Transcript.pdf
Creating an Uber Clone - Part XXVI - Transcript.pdf
ShaiAlmog1
 

Similar to For the following questions, you will implement the data structure to.pdf (20)

29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript
 
I need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfI need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdf
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfThis is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
 
In C#, visual studio, I want no more text boxes added, I have button.pdf
In C#, visual studio, I want no more text boxes added, I have button.pdfIn C#, visual studio, I want no more text boxes added, I have button.pdf
In C#, visual studio, I want no more text boxes added, I have button.pdf
 
The C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptxThe C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptx
 
Oop in java script
Oop in java scriptOop in java script
Oop in java script
 
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfCountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
 
C# Programming Help
C# Programming HelpC# Programming Help
C# Programming Help
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
 
Wien15 java8
Wien15 java8Wien15 java8
Wien15 java8
 
(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(국비지원학원/재직자교육/실업자교육/IT실무교육_탑크리에듀)#4.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
 
COMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdfCOMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdf
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf
FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdfFedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf
FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
 
Simple array Java code.The “Park-a-lot” parking garage currently o.pdf
Simple array Java code.The “Park-a-lot” parking garage currently o.pdfSimple array Java code.The “Park-a-lot” parking garage currently o.pdf
Simple array Java code.The “Park-a-lot” parking garage currently o.pdf
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app example
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
 
Creating an Uber Clone - Part XXVI - Transcript.pdf
Creating an Uber Clone - Part XXVI - Transcript.pdfCreating an Uber Clone - Part XXVI - Transcript.pdf
Creating an Uber Clone - Part XXVI - Transcript.pdf
 

More from arjunhassan8

Explain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdfExplain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdf
arjunhassan8
 
Does yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdfDoes yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdf
arjunhassan8
 
Determine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdfDetermine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdf
arjunhassan8
 
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdfDescribe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
arjunhassan8
 
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdfblackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
arjunhassan8
 
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdfBitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
arjunhassan8
 
2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf
arjunhassan8
 
^^^Q2. Discuss about Header Node    And also write a program fo.pdf
^^^Q2. Discuss about Header Node    And also write a program fo.pdf^^^Q2. Discuss about Header Node    And also write a program fo.pdf
^^^Q2. Discuss about Header Node    And also write a program fo.pdf
arjunhassan8
 
Write the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdfWrite the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdf
arjunhassan8
 
Which of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdfWhich of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdf
arjunhassan8
 
Which elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdfWhich elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdf
arjunhassan8
 
What domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdfWhat domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdf
arjunhassan8
 
This problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdfThis problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdf
arjunhassan8
 
The _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdfThe _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdf
arjunhassan8
 
The main difference between passive and active transport is the spec.pdf
The main difference between passive and active transport is  the spec.pdfThe main difference between passive and active transport is  the spec.pdf
The main difference between passive and active transport is the spec.pdf
arjunhassan8
 
The opposite movement of supination is ___. Pronation flexion exte.pdf
The opposite movement of supination is ___.  Pronation  flexion  exte.pdfThe opposite movement of supination is ___.  Pronation  flexion  exte.pdf
The opposite movement of supination is ___. Pronation flexion exte.pdf
arjunhassan8
 
The latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdfThe latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdf
arjunhassan8
 
The following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdfThe following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdf
arjunhassan8
 
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdfA female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
arjunhassan8
 
So I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdfSo I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdf
arjunhassan8
 

More from arjunhassan8 (20)

Explain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdfExplain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdf
 
Does yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdfDoes yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdf
 
Determine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdfDetermine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdf
 
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdfDescribe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
 
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdfblackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
 
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdfBitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
 
2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf
 
^^^Q2. Discuss about Header Node    And also write a program fo.pdf
^^^Q2. Discuss about Header Node    And also write a program fo.pdf^^^Q2. Discuss about Header Node    And also write a program fo.pdf
^^^Q2. Discuss about Header Node    And also write a program fo.pdf
 
Write the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdfWrite the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdf
 
Which of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdfWhich of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdf
 
Which elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdfWhich elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdf
 
What domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdfWhat domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdf
 
This problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdfThis problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdf
 
The _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdfThe _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdf
 
The main difference between passive and active transport is the spec.pdf
The main difference between passive and active transport is  the spec.pdfThe main difference between passive and active transport is  the spec.pdf
The main difference between passive and active transport is the spec.pdf
 
The opposite movement of supination is ___. Pronation flexion exte.pdf
The opposite movement of supination is ___.  Pronation  flexion  exte.pdfThe opposite movement of supination is ___.  Pronation  flexion  exte.pdf
The opposite movement of supination is ___. Pronation flexion exte.pdf
 
The latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdfThe latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdf
 
The following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdfThe following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdf
 
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdfA female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
 
So I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdfSo I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdf
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 

For the following questions, you will implement the data structure to.pdf

  • 1. For the following questions, you will implement the data structure to store information used by a local car dealer. Each car has some information and stored in a text files called cars: Write a main program for all questions to let the user enter, delete, search for information, and print current cars stored in the data structure. Cars formatted so car records separated by a blank line. Each record contains (in order, each in a single line): Make (manufacturer). Model, Year, Mileage, Price. Implement a double linked-list to store cars data. Write a double linked-list class including search, delete, append (to the head and tail), and remove (from the head and tail). Implement a FIFO queue of car data using the double linked-list. You can use the double linked list you wrote in Q1. Implement a max-heap of cars data that can extract the car with the highest price. Write a max-heap class including heapify, build heap, extract, and insertion. Implement a binary search tree of car data. Write a BST class including search, insertion, and deletion. Solution Cars.java package pacages; public class Cars { String make; String model; int year; double mileage; double price; // Setters and getters for the Cars member variables public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getModel() { return model; } public void setModel(String model) { this.model = model; }
  • 2. public int getYear() { return year; } public void setYear(int year) { this.year = year; } public double getMileage() { return mileage; } public void setMileage(double mileage) { this.mileage = mileage; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String toString() { return "Make: "+getMake()+ " Model: "+getModel()+ " Year: "+getYear() + " Mileage: "+getMileage() + " Price: "+getPrice(); } } DoublyLinkedList.java package pacages; class Node { protected Cars data; protected Node next, prev; /* Constructor */ public Node() {
  • 3. next = null; prev = null; data = null; } /* Constructor */ public Node(Cars d, Node n, Node p) { data = d; next = n; prev = p; } /* Function to set link to next node */ public void setLinkNext(Node n) { next = n; } /* Function to set link to previous node */ public void setLinkPrev(Node p) { prev = p; } /* Funtion to get link to next node */ public Node getLinkNext() { return next; } /* Function to get link to previous node */ public Node getLinkPrev() { return prev; } /* Function to set data to node */ public void setData(Cars d) { data = d; }
  • 4. /* Function to get data from node */ public Cars getData() { return data; } } /* Class linkedList */ public class DoublyLinkedList { protected Node start; protected Node end ; public int size; /* Constructor */ public DoublyLinkedList() { start = null; end = null; size = 0; } /* Function to check if list is empty */ public boolean isEmpty() { return start == null; } /* Function to get size of list */ public int getSize() { return size; } /* Function to insert element at begining */ public void appendAtHead(Cars val) { Node nptr = new Node(val, null, null); if(start == null)
  • 5. { start = nptr; end = start; } else { start.setLinkPrev(nptr); nptr.setLinkNext(start); start = nptr; } size++; } /* Function to insert element at end */ public void appendAtTail(Cars val) { Node nptr = new Node(val, null, null); if(start == null) { start = nptr; end = start; } else { nptr.setLinkPrev(end); end.setLinkNext(nptr); end = nptr; } size++; } /* Function to remove element at end */ public void deleteAtTail() { end = end.getLinkPrev(); end.setLinkNext(null); size-- ;
  • 6. } public void deleteAtHead() { start = start.getLinkNext(); start.setLinkPrev(null); size--; } /* Function to display the list */ public void display() { if (size == 0) { System.out.print("empty "); return; } if (start.getLinkNext() == null) { System.out.println(start.getData() ); return; } Node ptr = start; System.out.print(start.getData()+ " "); ptr = start.getLinkNext(); while (ptr.getLinkNext() != null) { System.out.print(ptr.getData()+ " "); ptr = ptr.getLinkNext(); } System.out.print(ptr.getData()+ " "); } }
  • 7. MaxHeap.java package pacages; public class MaxHeap { private Cars[] Heap; private int size; private int maxsize; private static final int FRONT = 1; public MaxHeap(int maxsize) { this.maxsize = maxsize; this.size = 0; Heap = new Cars[this.maxsize + 1]; Heap[0] = null; } private int parent(int pos) { return pos / 2; } private int leftChild(int pos) { return (2 * pos); } private int rightChild(int pos) { return (2 * pos) + 1; } private boolean isLeaf(int pos) { if (pos >= (size / 2) && pos <= size)
  • 8. { return true; } return false; } private void swap(int fpos,int spos) { Cars tmp; tmp = Heap[fpos]; Heap[fpos] = Heap[spos]; Heap[spos] = tmp; } private void maxHeapify(int pos) { if (!isLeaf(pos)) { if ( Heap[pos].getPrice() < Heap[leftChild(pos)].getPrice() || Heap[pos].getPrice() < Heap[rightChild(pos)].getPrice()) { if (Heap[leftChild(pos)].getPrice() > Heap[rightChild(pos)].getPrice()) { swap(pos, leftChild(pos)); maxHeapify(leftChild(pos)); }else { swap(pos, rightChild(pos)); maxHeapify(rightChild(pos)); } } } } public void insertion(Cars car) {
  • 9. Heap[++size] = car; int current = size-1; if(size>2) { while(Heap[current].getPrice() > Heap[parent(current)].getPrice()) { swap(current,parent(current)); current = parent(current); } } } public void maxHeap() { for (int pos = (size / 2); pos >= 1; pos--) { maxHeapify(pos); } } public Cars extraction() { Cars popped = Heap[FRONT]; Heap[FRONT] = Heap[size--]; maxHeapify(FRONT); return popped; } public void print() { for (int i = 1; i <= size / 2; i++ ) { System.out.print(" PARENT : " + Heap[i] + " LEFT CHILD : " + Heap[2*i]
  • 10. + " RIGHT CHILD :" + Heap[2 * i + 1]); System.out.println(); } } } BST.java package pacages; public class BST { Node root; // Constructor BST() { root = null; } public Node search(Node root, Cars car) { // Base Cases: root is null or key is present at root if (root==null || root.data.getMake().equals(car.getMake())) { if(root.data.getModel().equals(car.getModel())) { if(root.data.getYear() == car.getYear()) { if(root.data.getMileage() == car.getMileage()) { if(root.data.getPrice() == car.getPrice()) { return root; } } } } } // val is greater than root's key if (root.data.getPrice() > car.getPrice())
  • 11. return search(root.prev, car); // val is less than root's key return search(root.next, car); } Node insert(Node root, Cars car) { /* If the tree is empty, return a new node */ if (root == null) { root = new Node(car, null, null); return root; } /* Otherwise, recur down the tree */ if (car.getPrice() < root.data.getPrice()) root.prev = insert(root.prev, car); else if (car.getPrice() > root.data.getPrice()) root.next = insert(root.next, car); /* return the (unchanged) node pointer */ return root; } } MyClass.java package pacages; import java.util.Scanner; public class MyClass { static DoublyLinkedList list = new DoublyLinkedList(); static MaxHeap heap = new MaxHeap(100); static Scanner sc = new Scanner(System.in); public static void main(String args[]) { String choice = "y";
  • 12. int menuChoice = 0; do { System.out.println("MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first Car data 4. Display all Cars 5. Exit"); menuChoice = sc.nextInt(); switch(menuChoice) { case 1: getCarDetails(); break; case 2: list.deleteAtTail(); break; case 3: list.deleteAtHead(); heap.extraction(); break; case 4: list.display(); } System.out.println("Do you wish to continue? y or n"); choice = sc.next(); }while(choice.equals("y") || choice.equals("Y")); } public static void getCarDetails(){ Cars car = new Cars(); System.out.println("Enter Make: "); car.setMake(sc.next()); System.out.println("Enter Model: "); car.setModel(sc.next()); System.out.println("Enter Year: "); car.setYear(sc.nextInt()); System.out.println("Enter Mileage: "); car.setMileage(sc.nextDouble()); System.out.println("Enter Price: ");
  • 13. car.setPrice(sc.nextDouble()); list.appendAtTail(car); heap.insertion(car); } } OUTPUT: MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first Car data 4. Display all Cars 5. Exit 1 Enter Make: Hyundai Enter Model: 324rtf Enter Year: 2011 Enter Mileage: 30.0 Enter Price: 945677 Do you wish to continue? y or n y MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first Car data 4. Display all Cars 5. Exit 1 Enter Make: Toyota Enter Model: 375jdg
  • 14. Enter Year: 2005 Enter Mileage: 25.0 Enter Price: 673522 Do you wish to continue? y or n y MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first Car data 4. Display all Cars 5. Exit 4 Make: Hyundai Model: 324rtf Year: 2011 Mileage: 30.0 Price: 945677.0 Make: Toyota Model: 375jdg Year: 2005 Mileage: 25.0 Price: 673522.0 Do you wish to continue? y or n y MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first Car data 4. Display all Cars 5. Exit 2 Do you wish to continue? y or n y MENU 1. Enter car Details 2. Delete Last car Data 3. Delete first Car data 4. Display all Cars 5. Exit 4 Make: Hyundai Model: 324rtf Year: 2011 Mileage: 30.0 Price: 945677.0
  • 15. Do you wish to continue? y or n n