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"); } }
2 odpowiedzi
+ 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");
}
}
+ 1
thank you for your answers, i appreciate that