0

Whats wrong with my code? Test 3 is the only one who failed

Popsicles

5th Feb 2020, 12:33 PM
Aiza
Aiza - avatar
4 Respostas
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int siblings = input.nextInt(); int popsicles = input.nextInt(); //your code goes here if(siblings %2==0 && popsicles %2==0){ System.out.println("give away"); } else{ System.out.println("eat them yourself"); } } } here is my code
5th Feb 2020, 12:33 PM
Aiza
Aiza - avatar
0
Both integers siblings and popsicles being divisible by 2 doesnt mean that popsicles % siblings == 0.
5th Feb 2020, 12:36 PM
KnuckleBars
KnuckleBars - avatar
0
Example: Popsicles = 12 Siblings = 8 Both are divisible by 2 but cannot be divided without a remainder. Change your condition in the if - else statement.
5th Feb 2020, 12:37 PM
KnuckleBars
KnuckleBars - avatar
0
Thanks
5th Feb 2020, 12:38 PM
Aiza
Aiza - avatar