I am trying to get user input for Yes or No (Y or N), but I keep running into complications. I also have to make it so that lowercase y and n work. I was wondering what the best way to go about this would be? Here is my program:
import java.util.Scanner;
public class Homework2 {
public static void main(String args[]) {
System.out.println("\nWould you like to see some healthy weight loss guidelines? (Y or N)");
char decision = (char) System.in.read();
if (decision.equals("Y")) {
System.out.println("\nPlaceholder");
} else if (decision.equals("N")) {
System.out.println("\n");
System.out.println("========================================================");
System.out.println("|| ||");
System.out.println("|| Thank you From Your Friends At ||");
System.out.println("|| Happy Valley Fitness Center! ||");
System.out.println("|| ||");
System.out.println("========================================================");
} else {
System.out.println("\nYou did not enter yes or no, program stopping");
System.out.println("\n");
System.out.println("========================================================");
System.out.println("|| ||");
System.out.println("|| Thank you From Your Friends At ||");
System.out.println("|| Happy Valley Fitness Center! ||");
System.out.println("|| ||");
System.out.println("========================================================");
}
}
}