Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task-1 : Modify the above program to implement a QUEUE in a bank as depicted by the following sample output: i. Provide the menu as

image text in transcribed
image text in transcribed
Task-1 : Modify the above program to implement a QUEUE in a bank as depicted by the following sample output: i. Provide the menu as shown below. Run the program in a loop; stop when user opts 4. ii. Add a customer should add an int at the end using the method addLast(). iii. Remove a customer should delete the int at front using the method removeFirst(). iv. Show the queue should display the queue using the method System.out.println(). Queueina Bank 1. Adkl a customer 2. Remove a customer 3. Show the queue 4. Exit Your choice? Added customer1 Qucus in a Bank Queueina Bank 1. Add a customer 2. Remove a customer. Add a customer 3. Show the queue 2. Remove a customer 4. Exit 3. Show the queue 4. Exit Your choice? Your choice?! Added customer #2 Added customer #3 Queueina Bank Qucus ina Bank 1. Add a customer 1. Add a customer 2. Remove a customer 2. Renwave a customer 3. Show the queue 3. Show the queue 4. Exit 4. Exit Your choice? 2 Your choice? 3 Removed customer #1 Queue 1,2,3 Queue - 2.3 Page 3 of 3 6. 10. 14. 15. 16. 18. 20. 21. Exercise #2 : Edit, compile and run the following code in NetBeans. TestLinkedLists.java 1. import java.io.*; 2. import java.util.LinkedList; 3. class TestLinkedLists { 4. public static void main(String[] ar) { 5. LinkedList 1st1 = new LinkedListo); // Ist1 = [] 1st1.addFirst(new Integer (4)); // Ist1 = [4] 7. 1st1.addFirst (new Integer (5)); // Ist1 = 15, 4] 8. 1st1.addlast(new Integer(6)); // Ist1 = [5, 4, 6] 9. 1st1.addlast(new Integer (5)); // 1st1 = 15, 4, 6, 5] System.out.println("Isti: + lsti); // Isti = [5, 4, 6, 5] 11. System.out.println (1sti.lastIndexOf(new Integer (5)));// 3 12. System.out.println(Ist1.indexOf(new Integer (5)); // 13. System.out.println(1st1.indexOf(new Integer (7))); // -1 1st1.remove(new Integer(5)); // lst1 = [4, 6, 5] LinkedList ist2 = new LinkedList(1st1); 11 1st2 = [4, 6, 5] 1st2.add( 2, new Integer(8)); // Ist2 [4, 6, 8, 5] 17. 1st2.remove(new Integer (5)); // Ist2 [4, 6, 8] 1st2.remove(1); // Ist2 [4, 8] 19. System.out.println(1st2.getFirst()+" "+1st2.getLast()); // 4 8 System.out.println(1st2.set(1, new Integer (7))); //8, 1st 2=[4,7] Integer[] b = {new Integer(i), new Integer (2)}; 11 6 = [1, 21 for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions