14.2k views
0 votes
When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return true if the party with the given values is successful, or false otherwise.

A cigarParty(30, false) → false
B cigarParty(50, false) → true
C cigarParty(70, true) → true

User Pgfearo
by
7.5k points

1 Answer

3 votes

Final answer:

A squirrel party is successful if the number of cigars is between 40 and 60, inclusive, unless it is the weekend. If it is the weekend, the party is successful regardless of the number of cigars.

Step-by-step explanation:

The given problem states that a squirrel party is successful when the number of cigars is between 40 and 60, inclusive. However, if it is the weekend, there is no upper bound on the number of cigars.

To determine if the party is successful, we need to check two conditions:

  1. If it is the weekend, return true since there is no upper bound on the number of cigars.
  2. If it is not the weekend, check if the number of cigars is between 40 and 60, inclusive. If it is, return true; otherwise, return false.

Example:

For the function call cigarParty(50, false), the function should return true because the number of cigars (50) is between 40 and 60, inclusive.

User Galymzhan
by
8.6k points