java - My breaks won't fire after if statement -


import java.util.scanner;  public class emptest {      public static scanner input = new scanner(system.in);      public static void main(string[] args) {  // there second class constructors , other stuff of nature                  employee e1 = new employee();          employee e2 = new employee();         employee e3 = new employee();         string no = "no";         string yes = "yes";         while (true) {              system.out.println("please enter in employee name");             e1.name = input.nextline();             system.out.println("please enter in salary of employee");             e1.salary = input.nextdouble();             while (true) {                 system.out.println("would add second employee?");                  string userinput = input.next();                 if (userinput.equalsignorecase(yes)) {                     system.out.println("please enter in employee name");                     e2.name = input.next();                     system.out.println("please enter in salary of employee");                     e2.salary = input.nextdouble();                 }  //this break wont terminate loop //the console output asks second employee salary , name without waiting user input                  if(userinput.equalsignorecase(no)) {                     system.out.println("okay");                     break;                 }                  system.out.println("would add third employee?");                  userinput = input.next();                 if (userinput.equalsignorecase(yes)) {                     system.out.println("please enter in employee name");                     e3.name = input.next();                     system.out.println("please enter in salary of employee");                     e3.salary = input.nextdouble();                 }                  if(userinput.equalsignorecase(no)) {                     system.out.println("okay");                     break;                 }              }          }      } } 

your break statement breaking inner while loop no break statement outer while loop.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -