import java.util.Scanner;
public class EmpTest {
public static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
// there is a second class with my constructors and other stuff of that 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 the employee name");
e1.name = input.nextLine();
System.out.println("Please enter in the salary of that employee");
e1.salary = input.nextDouble();
while (true) {
System.out.println("Would you like to add a second employee?");
String userInput = input.next();
if (userInput.equalsIgnoreCase(yes)) {
System.out.println("Please enter in the employee name");
e2.name = input.next();
System.out.println("Please enter in the salary of that employee");
e2.salary = input.nextDouble();
}
//this is where my break wont terminate the loop
//the console output just asks for the second employee salary and name without waiting for a user input
if(userInput.equalsIgnoreCase(no)) {
System.out.println("Okay");
break;
}
System.out.println("Would you like to add a third employee?");
userInput = input.next();
if (userInput.equalsIgnoreCase(yes)) {
System.out.println("Please enter in the employee name");
e3.name = input.next();
System.out.println("Please enter in the salary of that employee");
e3.salary = input.nextDouble();
}
if(userInput.equalsIgnoreCase(no)) {
System.out.println("Okay");
break;
}
}
}
}
}
mardi 27 octobre 2015
My breaks wont fire after if statement
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire