Code coach popsicle problem (Java) | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Code coach popsicle problem (Java)

My code gets 4/5 of the problems right but I don't understand whats wrong with the 5th variation of the problem since I can't see ithers my code : import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); double siblings = input.nextInt(); double popsicles = input.nextInt(); double amount = 1.0; //your code goes here if (siblings > 0) { amount = popsicles/siblings; } if (amount % 2 == 0){ System.out.println("give away");} else { System.out.println("eat them yourself"); } } }

5th Oct 2023, 6:55 AM
zEscOOt
zEscOOt - avatar
1 ответ
+ 1
Might be if(siblings>0)? My solution worked with ints instead of doubles and simple if(popsicles%siblings==0). Revrited your solution into my code- doubles aint problem, test 5 failed when your amount=popsicles/siblings added
5th Oct 2023, 7:42 AM
Drelda
Drelda - avatar