I am having some issues with my scanner in my program.
System.out.print("Do you smoke?(y/n): ");
String isSmoker = console.nextLine();
boolean smoker = false;
if (isSmoker.equalsIgnoreCase("y")) {
smoker = true;
}
This part of the program is not letting me enter a response to the question, and instead just skips ahead to the next part of the program and then ends. Later on in the program, there are methods for calculating BMI and getting costs for insurance. When I run the program, this is what happens, for instance:
Welcome to our new Health Plan!
When prompted, enter the health plan in which you would like to enroll:
E (E-mployee), C (Employee/C-hildren), S (Employee/S-pouse), F (Employee/F-amily).
You will be asked whether or not you smoke and for your weight and height.
If you choose plan S or F, you will be asked whether your spouse smokes and for
his/her weight and height. Your monthly health plan premium will then be displayed.
Heath Plan (E-mployee, C-hildren, S-pouse, F-amily):
C
Weight (lb): 128
Height (in): 62
Do you smoke?(y/n): 23.408949011446413Monthly Health Plan Premium: 245
MacBook-Pro:src cs$
How can I make the question for smoking accept responses in the console? Am I to use nextBoolean instead of nextLine?