I have a problem and I can not fig it out.
Here is what I need.
I have scanner when that ask a Question either yes (Y) or no (N).
if Y is enter then they go to the next level which they can enter a product. This part works ok.
if N is enter then an a System.out.prin tln("Thank You"). Problem here is either I get a endless loop of Thank you or I get a thank you and then it move to the next level.
Here is my code.
Any info would be great.
Thanks
sandy
Here is what I need.
I have scanner when that ask a Question either yes (Y) or no (N).
if Y is enter then they go to the next level which they can enter a product. This part works ok.
if N is enter then an a System.out.prin tln("Thank You"). Problem here is either I get a endless loop of Thank you or I get a thank you and then it move to the next level.
Here is my code.
Code:
// Prompt the user Do you want to create a new product yes or no // make a scanner for the response Scanner kbd_answer = new Scanner(System.in); // add loop info here for result Y or N System.out.print("\nPlease press Enter afer each response"); System.out.print("\nDo you want to create a Product? (Y/N): "); answer_flag = kbd_answer.next(); while (answer_flag.equalsIgnoreCase("N")){ System.out.println("Thank You"); break; } // need to figure out how to close the loop // Make a scanner for product Scanner kbd_product = new Scanner(System.in); // scanner called // kbd_product System.out.print("\nEnter the Product Name: "); product_flag = kbd_product.next(); // scanner value is now called
Thanks
sandy
Comment