We want the program to use a DEQueue object to create a sorted list of names. The program gives a user the following three options to choose from – insert, delete, and quit. If the user selects ‘insert’, the program should accept a name (String type) from the user and insert it into the deque in a sorted manner. If the user selects ‘delete’, the program should accept a name (String type) from the user and delete that name from the deque. Display the contents of deque after each insert/delete operation. The program continues to prompt the user for options until the user chooses to quit. You have to implement the insert and delete operations.   *Using a skeleton

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

We want the program to use a DEQueue object to create a sorted list of names. The program gives a user the following three options to choose from – insert, delete, and quit. If the user selects ‘insert’, the program should
accept a name (String type) from the user and insert it into the deque in a sorted manner. If the
user selects ‘delete’, the program should accept a name (String type) from the user and delete
that name from the deque. Display the contents of deque after each insert/delete operation. The
program continues to prompt the user for options until the user chooses to quit. You have to
implement the insert and delete operations.

 

*Using a skeleton

A
*AppPart2.java X Dequelnterface.java
1 package assign4DEQ;
2
3 import java.util.Scanner;
4
50 /**
6 * COSC 2100 - Spring 2023
7 * Assignment#4
8
9 * @author Dr.. edited by Julianne Browne
*/
10
11
12 public class AppPart2 {
13
140
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
* Create a sorted list of names
236
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 }
System.out.print("1: insert, ");
System.out.print("2: delete, ");
System.out.println("3: quit");
public static void main(String[] args) {
DEQueue<String> names = new DEQueue<String>();
Scanner scan = new Scanner(System.in);
int operation;
// indicates user's choice of operation
boolean keepGoing = true; //to help with quit option
while (keepGoing) {
System.out.print("\nChoose an operation - "');
if (scan.hasNextInt())
else{
operation = scan.nextInt ();
return;
*DEQueue.java
}
switch (operation) {
case 1:
System.out.println("Error: you must enter an integer.");
System.out.println("Terminating test.");
case 3: // quit
keepGoing
//TODO (6) Implement the insert operation
break;
case 2: //TODO (7) Implement the delete operation
break;
break;
default:
*DLLNode.java
false;
System.out.println("Goodbye!!");
=
return;
}//end of switch
}//end of while
scan.close();
QueueUnderflowException.java
System.out.println("Error in operation choice. Terminating test.");
Writable
Smart Insert
9:16:143
0
U
—
Transcribed Image Text:A *AppPart2.java X Dequelnterface.java 1 package assign4DEQ; 2 3 import java.util.Scanner; 4 50 /** 6 * COSC 2100 - Spring 2023 7 * Assignment#4 8 9 * @author Dr.. edited by Julianne Browne */ 10 11 12 public class AppPart2 { 13 140 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 * Create a sorted list of names 236 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 } System.out.print("1: insert, "); System.out.print("2: delete, "); System.out.println("3: quit"); public static void main(String[] args) { DEQueue<String> names = new DEQueue<String>(); Scanner scan = new Scanner(System.in); int operation; // indicates user's choice of operation boolean keepGoing = true; //to help with quit option while (keepGoing) { System.out.print("\nChoose an operation - "'); if (scan.hasNextInt()) else{ operation = scan.nextInt (); return; *DEQueue.java } switch (operation) { case 1: System.out.println("Error: you must enter an integer."); System.out.println("Terminating test."); case 3: // quit keepGoing //TODO (6) Implement the insert operation break; case 2: //TODO (7) Implement the delete operation break; break; default: *DLLNode.java false; System.out.println("Goodbye!!"); = return; }//end of switch }//end of while scan.close(); QueueUnderflowException.java System.out.println("Error in operation choice. Terminating test."); Writable Smart Insert 9:16:143 0 U —
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT