The assignment says "using conditionals and a while loop, prompt the user to either ask another question of thank them for using the program, depending on what they decide."
Trying to figure out how to use a while loop to continuously prompt the user to decide if they would like to continue. Wouldn't I need a new scanner each time?
Also, my program stops right after the user enters yes or no in the second scanner. Ahhhhhh.
Here's what I'm working with:
   System.out.println("Hello!\nNeed to make a decision?\nWant to know about the future?\nType in a yes or no question and press Enter: ");
   Scanner reader = new Scanner(System.in);
   String question = reader.nextLine();
   System.out.println();
   Random generator = new Random();
   int rand = generator.nextInt(20) + 1;
   if (rand == 1)
   { System.out.println("It is certain.");}
   if (rand ==2) 
   {System.out.println("It is decidedly so."); }
   if (rand ==3)
   {System.out.println("Without a doubt."); }
   if (rand ==4) 
   { System.out.println("Yes, definitely.");}
   if (rand ==5)
   {System.out.println("You may rely on it.");}
   if (rand == 6)
   {System.out.println("As I see it, yes."); }
   if (rand == 7)
   {System.out.println("Most likely.");}
   if (rand == 8)
   {System.out.println("The outlook is good");}
   if (rand == 9)
   {System.out.println("Yes.");}
   if (rand == 10)
   {System.out.println("Signs point to yes.");}
   if (rand == 11)
   {System.out.println("Reply hazy.");}
   if (rand == 12)
   {System.out.println("Ask again later.");}
   if (rand == 13)
   {System.out.println("Better not tell you now.");}
   if (rand ==14)
   {System.out.println("Cannot predict now.");}
   if (rand ==15)
   {System.out.println("Concentrate and ask again.");}
   if (rand == 16)
   {System.out.println("Don't count on it.");}
   if (rand == 17)
   {System.out.println("My reply is no.");}
   if (rand ==18)
   {System.out.println("My sources say no.");}
   if (rand == 19)
   {System.out.println("Outlook does not look so good.");}
   if (rand == 20)
   {System.out.println("Very doubtful.");}
   System.out.print("\nWould you like to ask another question?: ");
   Scanner reader2 = new Scanner(System.in);
   String YesNo = reader2.nextLine(); 
   if (YesNo == "no") {
       System.out.println("Thanks for playing!"); } 
   while (YesNo == "yes") {   
   System.out.println("Enter your question: ");
   Scanner reader3 = new Scanner(System.in);
   String question2 = reader3.nextLine();
   Random generator2 = new Random();
   int rand2 = generator.nextInt(20) + 1;
   System.out.println();
   if (rand2 == 1)
   { System.out.println("It is certain.");}
   if (rand2 ==2) 
   {System.out.println("It is decidedly so."); }
   if (rand2 ==3)
   {System.out.println("Without a doubt."); }
   if (rand2 ==4) 
   { System.out.println("Yes, definitely.");}
   if (rand2 ==5)
   {System.out.println("You may rely on it.");}
   if (rand2 == 6)
   {System.out.println("As I see it, yes."); }
   if (rand2 == 7)
   {System.out.println("Most likely.");}
   if (rand2 == 8)
   {System.out.println("The outlook is good");}
   if (rand2 == 9)
   {System.out.println("Yes.");}
   if (rand2 == 10)
   {System.out.println("Signs point to yes.");}
   if (rand2 == 11)
   {System.out.println("Reply hazy.");}
   if (rand2 == 12)
   {System.out.println("Ask again later.");}
   if (rand2 == 13)
   {System.out.println("Better not tell you now.");}
   if (rand2 ==14)
   {System.out.println("Cannot predict now.");}
   if (rand2 ==15)
   {System.out.println("Concentrate and ask again.");}
   if (rand2 == 16)
   {System.out.println("Don't count on it.");}
   if (rand2 == 17)
   {System.out.println("My reply is no.");}
   if (rand2 ==18)
   {System.out.println("My sources say no.");}
   if (rand2 == 19)
   {System.out.println("Outlook does not look so good.");}
   if (rand2 == 20)
   {System.out.println("Very doubtful.");}
   System.out.print("\nWould you like to ask another question?: ");
}
}
}
 
     
     
    