I need to complete this project by next Monday.
How do I do a menu selection
EXAMPLE:
Press 1 to enter the model number.
Press 2 to delete a record.
Press 3 to exit the program.
I'm doing this project on NetBean using Java.
Can someone please teach me?
Thanks!!!!

My java is a little rusty, but this should give you the basic idea (I'm doing this from memory, so the code might not compile just right, but you should be able to fix it from there):

BufferedReader reader = new BufferedReader(new InputStreamReader());
int choice = int(reader.readLine().trim());

if (choice == 1) {
    // call the function corresponding to choice 1
} elseif {
    // do something else
} // etc..

Edited 5 Years Ago by inspectorG4dget: n/a

My java is a little rusty, but this should give you the basic idea (I'm doing this from memory, so the code might not compile just right, but you should be able to fix it from there):

BufferedReader reader = new BufferedReader(new InputStreamReader());
int choice = int(reader.readLine().trim());

if (choice == 1) {
    // call the function corresponding to choice 1
} elseif {
    // do something else
} // etc..

I aldready had a BufferedReader, do i need to create a new one?

No I think. You can use the existing one.

I think using that code but there is an error

Ok. What kind of menu selection are you using? You can use the below code

import java.io.*;
public test{
public static void main(String args[]) throws IOException
{
BufferedReader bfr= new 
BufferedReader(new InputStreamReader(System.in));
System.out.println("MENU");
System.out.println("enter a number");
int n=Integer.parseInt(bfr.readLine());
if(n==1)
{
//condition  
System.out.println("number is one");
}
else if(n==2)
{
//condition  
System.out.println("number is two");
}
else if((n>2)&&(n<1))
{
//condition  
System.out.println("sorry wrong number");
}
}
}

Edited 5 Years Ago by __avd: Added [code] tags.

I adlready have a public class and public static void main. Do i need to create a new one?

No. Actually you don't need to. You can use the lines between public main class that is from buffered reader and use it in your class. If you need any help you can reply me to my mail. SNIP

Edited 5 Years Ago by happygeek: keep help in the forum please

I am completely confused about what this thread is, and what everybody has posted. It seems to be a jumble of different unrelated threads all thrown into one.

This question has already been answered. Start a new discussion instead.