0

can someone help about this popsicle question? I can't see the the test case 3 because it needs pro version

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 % popsicles ) == 10||(siblings % popsicles ) == 0){ System.out.print("give away"); }else if((siblings % popsicles ) > 0 || (siblings % popsicles ) < 10) System.out.print("eat them yourself"); } }

29th Jul 2021, 4:05 AM
Tristan Jarred Federizo
Tristan Jarred Federizo - avatar
2 Antworten
+ 3
1. you dont need if((siblings % popsicles ) > 0 || (siblings % popsicles ) < 10) or (siblings % popsicles ) == 10|| 2. use (popsicles % siblings ) == 0 instead of (siblings % popsicles ) == 0 This works fine: 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((popsicles % siblings ) == 0){ System.out.print("give away"); }else System.out.print("eat them yourself"); } }
29th Jul 2021, 4:47 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
thank you for your answers, i appreciate that
29th Jul 2021, 5:48 AM
Tristan Jarred Federizo
Tristan Jarred Federizo - avatar