Groundhogs at a party

Report a typo

Groundhogs like to throw fun parties, and at their parties, they like to eat Reese's peanut butter cups. But not too many of them, or they feel sick! A successful groundhog party will have between 10 and 20 Reese's peanut butter cups, inclusive, unless it is the weekend, in which case they will need 15 to 25 Reese's peanut butter cups, inclusive.

Write a Java program that reads two values:

  • the first is the number of Reese's peanut butter cups;

  • the second is a boolean representing whether it is the weekend.

The program must print a boolean value that indicates whether the party was successful.

Once you have read the input values, you need to determine whether the party was successful. To do this, you'll need to check two conditions: one for weekdays and another for weekends. Remember to consider the inclusive ranges specified in the problem statement.

Sample Input 1:

5 true

Sample Output 1:

false

Sample Input 2:

16 false

Sample Output 2:

true
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// put your code here
// You can use scanner.nextBoolean() to read a boolean value
}
}
___

Create a free account to access the full topic