I wrote a program for school, which is supposed to ask for the day of the week, whether or not it is vacation, and then print out whether the user can sleep in. However, the Boolean values, sleepInDay(which decides whether it is a weekday or not) and sleepInDayV (which decides whether or not it is a vacation) both automatically change to false, even when I change their default values to true at the beginning of the code.
import java.io.*;
class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
InputStreamReader istream = new InputStreamReader(System.in);
BufferedReader bufRead = new BufferedReader (istream);
boolean sleepInDay;
boolean sleepInDayV;
System.out.println("Please enter the day of the day" );
String dayOfTheWeek = bufRead.readLine();
if (dayOfTheWeek == "Sunday") {
sleepInDay = true;
} else if (dayOfTheWeek == "Saturday") {
sleepInDay = true;
} else {
sleepInDay = false;
}
System.out.println("Is it vacation?" );
String Vacation = bufRead.readLine();
if (Vacation == "Yes") {
sleepInDayV = true;
} else {
sleepInDayV = false;
};
System.out.println(sleepInDay + " " + sleepInDayV);
if ( sleepInDay == true || sleepInDayV == true) {
System.out.println("You get to sleep in!");
} else {
System.out.println("GET UP!");
}
} catch(IOException err) {
System.out.println("Error reading line");{
}
Thanks for the help, Kitten Taco