i'm a beginner at java and i'm trying to create a program that asks a user to enter a month, and prints the number of days in that month, as well as asking if it is a leap year. I've tried converting a String "yes" input from the scanner, into a boolean true or false input, however, i keep receiving the error cannot convert string into boolean. I've tried the parseString method however with no success. Any insight or help into this issue is greatly appreciated. Thanks for your time!
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int numberOfDays = 0;
System.out.print("What's the month? ");
String month = scan.nextLine();
System.out.print("Is it a leap year? ");
String leapYear = scan.nextLine();
boolean b1 = Boolean.parseBoolean(leapYear);
if (b1 = "yes") {
b1 = true;
}
else {
b1 = false;
}
switch(month) {
case "January":
numberOfDays = 31;
break;
case "February":
if (b1 = true) {
numberOfDays = 29;
} else {
numberOfDays = 28;
}
break;
}
}