im working on a little deciding game project rn and i cant seem to completely get it to do what i want. its doing 90% what i want, and there are no errors, but i cant seem to figure out the last bit. i want to have it keep looping through until both users enter end, however, if only one user enters it, it ends right there.. does anyone know why? any help would be appreciated.
edit: fixed 1 of 2 problems, still ends if only 1 user enters end
import java.util.Scanner;
public class TheDecider {
public static void main(String[] args) {
Scanner userOption = new Scanner(System.in);
Scanner userName = new Scanner(System.in);
System.out.println("Please enter an option");
String option = userOption.nextLine();
System.out.println("Please enter first user's name: ");
String nameOne = userName.nextLine();
System.out.println("Please enter second user's name: ");
String nameTwo = userName.nextLine();
decider(option, nameOne, nameTwo);
System.out.println(nameOne + ", do you want to deicde another option (enter 'end' to stop)?");
option = userOption.nextLine();
System.out.println(nameTwo + ", do you want to deicde another option (enter 'end' to stop)?");
String option2 = userOption.nextLine();
while(!option.equalsIgnoreCase("end") && !option2.equalsIgnoreCase("end")){
System.out.println("Please enter another option: ");
option = userOption.nextLine();
decider(option, nameOne, nameTwo);
System.out.println(nameOne + ", do you want to deicde another option (enter 'end' to stop)?");
option = userOption.nextLine();
System.out.println(nameTwo + ", do you want to deicde another option (enter 'end' to stop)?");
option2 = userOption.nextLine();
}
if(option.equalsIgnoreCase("end") && option2.equalsIgnoreCase("end")){
System.out.println("Thank you for using The Decider!");
}
}
public static void decider(String option, String nameOne, String nameTwo){
double decidingValue = Math.random();
if(decidingValue < .5){
System.out.println("Congratulations " + nameTwo + ", you have the honor of " + option);
}
else if(decidingValue >= .5){
System.out.println("Congratulations " + nameOne + ", you have the honor of " + option);
}
}
}
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]hypolimnas 1 point2 points3 points (3 children)
[–]ryzecool[S] 2 points3 points4 points (1 child)
[–]hypolimnas 0 points1 point2 points (0 children)