I am trying to create a simple console program that asks a user if they want to create a list and if 'yes', allow them to enter the name of the list. It should then 'print' the name of the list before exiting the program.
My code allows the user to say y or n, for the first part but in my conditional statement it does not let the user input the name of the list; it just completes the program. There is no error message; it just isn't functioning as I expected. Here is my code:
public static void main(String[] args) throws IOException
{
getAnswers();
}
public static void getAnswers()throws IOException{
char answer;
String listName;
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
System.out.println ("Would like to create a list (y/n)? ");
answer = (char) br.read();
***if (answer == 'y'){
System.out.println("Enter the name of the list: ");
listName = br.readLine();
System.out.println ("The name of your list is: " + listName);}***
//insert code to save name to innerList
else if (answer == 'n'){
System.out.println ("No list created, yet");
}
//check if lists exist in innerList
// print existing classes; if no classes
// system.out.println ("No lists where created. Press any key to exit")
}
Thank you in advance for your time and help in this!