hi everyone,
i am very new in java. i am having problem in SWITCH CASE STATEMENT. can anyone please help me to solve the following problem:

you have to write a program in java to generate the following menu with submenus:

LinkedList

1: ADD ELEMENT
1-1: add first
1-2: add last
1-3: back to main menu

2: REMOVE ELEMENT
2-1: remove first
2-2: remove in between
2-3: remove last
2-4: back to main menu

3: OTHER FUNCTIONS
3-1: peek first
3-2: peek last
3-3: poll first
3-4: poll last
3-5: back to main

4: DISPLAY

5. EXIT

thank you,
regards,
al_buotan

Recommended Answers

All 3 Replies

please show your codes here and specify the errors..

please show your codes here and specify the errors..

import java.util.*;
import java.io.*;

public class MidProj
{
   public static void main(String[] args)
   {
        Scanner con = new Scanner(System.in);
        LinkedList<Integer> lst = new LinkedList<Integer>();
        int x;
        int x1;
        
        
        System.out.print("1. Add Element \n 2. Remove Element \n 3. Other Functions \n 4. Display \n 5. Exit \n Enter your choice: ");
        x = con.nextInt();
        
        switch (x) 
        {
            case 1: System.out.print("1. Add First \n 2. Add Last \n 3. Back to Main Menu \n Enter your choice: ");
                    x1 = con.nextInt();
                    switch (x1)
                    {
                        case 1: System.out.println("Add First: "); lst.addFirst;
                                break;
                        case 2: lst.addLast;
                                break;
                        case 3: 
                    }
            case 2: menuB();
                    break;
            case 3: menuC();
                    break;
            case 4: System.out.println(lst);
                    break;
            case 5: System.exit();
        }
   }
   
}

It is incomplete. Im not finish this yet. I hope you can have any suggestions.


best regards,
al_buotan

You are going right here such a menu would require a nested switch implementation which you are on your way to do, so what are the errors you are getting and where do you need our help ?

Also stop starting multiple threads for the same question, be patient if the replies take time to come by and more appropriately please read the replies if someone has already written them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.