Java > Warmup-1 > sleepIn (CodingBat Solution)

Problem:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true


Solution:

public boolean sleepIn(boolean weekday, boolean vacation) {
  if (weekday == true && vacation == false)
    return false;
  else
    return true;
}


3 comments :

  1. public boolean sleepIn(boolean weekday, boolean vacation) {
    return !weekday ||vacation;
    }

    ReplyDelete
  2. Can someone please tell me the algorthm steps for this. Example step 1: start and etc

    ReplyDelete

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact