Coding Bat – sleepIn

This exercise requires that the program return “true” if it is OK to sleep in on a given day. The rules are that you can sleep-in on a day that is not a weekday or on a vacation day.

Here is the code that you start with:

public boolean sleepIn(boolean weekday, boolean vacation) {
 
}

As you can see, we have a boolean named weekday and a boolean named vacation.

public boolean sleepIn(boolean weekday, boolean vacation) {
  if (!weekday || vacation) {
    return true;
  }  
  return false;
}

The solution uses a boolean conditional of if the value is NOT a weekday OR a vacation, it will return true, otherwise it will return false.

Leave a Reply

Your email address will not be published. Required fields are marked *