0

Popsicles query error. If 2 siblings are there and I have 5 popsicles then I should give them away... But compiler showing eatem

You have a box of pop and you want to give them all away to a group of brothers and sisters. If you have enough left in the box to give them each an even amount you should go for it! If not, they will fight over them, and you should eat them yourself later. Task Given the number of siblings that you are giving popsicles to, determine if you can give them each an even amount or if you shouldn't mention the pop at all. Input Format Two integer values, the first one represents the number of siblings, and the second one represents the number of pop that you have left in the box. Output Format A string that says 'give away' if you are giving them away, or 'eat them yourself' if you will be eating them yourself. ****** So when compiler is checking 2 siblings 5 popsicles, I think output should be give them... But compiler showing output should be eat them all... Am I not getting something or compilers answer is wrong please tell. Code is in c++ https://code.sololearn.com/cUFd55IWQh69/?ref=app

2nd Jan 2020, 4:10 AM
Vishal Sharma
Vishal Sharma - avatar
17 odpowiedzi
+ 6
This is the solution. Check it out. siblings = int(input('Number of siblings: ')) popsicles = int(input('Number of popsicles: ')) if popsicles % siblings == 0: print('give away') else: print('eat them yourself')
21st Sep 2020, 8:03 AM
Silas Barimah
+ 4
Is this even close?!?! siblings = int(input()) popsicles = int(input()) def siblings % popsicles = return if (int) print "siblings" else print "eat em myself"
25th Jan 2020, 7:07 PM
Tacklebiscuit
+ 3
Can somebody help me with this...
25th Jan 2020, 7:03 PM
Tacklebiscuit
+ 2
Vishal Sharma You can make it like this : if(popsicles %siblings==0) And if you need anything please tell me
2nd Jan 2020, 4:24 AM
ycsvenom
ycsvenom - avatar
+ 2
😢
25th Jan 2020, 7:08 PM
Tacklebiscuit
+ 2
My java task: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int siblings = input.nextInt(); int popsicles = input.nextInt(); if(popsicles % siblings == 0){ System.out.println("Give away"); } else { System.out.println("eat them yourself"); } } }
14th Apr 2020, 7:01 AM
Эрика
+ 2
how do you solve this question ysing Swift?
21st Sep 2020, 7:56 AM
Silas Barimah
+ 2
this solution is quite simple. siblings = int(input('Number of siblings: ')) popsicles = int(input('Number of popsicles: '))
21st Sep 2020, 8:01 AM
Silas Barimah
+ 2
// C++ #include <iostream> using namespace std; int main() { int siblings, popsicles; //take input cin>>siblings>>popsicles; //your code goes here if (popsicles % siblings == 0) { cout << "give away" << endl; } else { cout << "eat them yourself" << endl; } return 0; }
21st Sep 2021, 3:13 AM
Malik Mehrab Rashid
Malik Mehrab Rashid - avatar
+ 2
Well, in fact, if you have 2 siblings and 5 pops. You eat them, because you cant give them the same amount of pops. And this is like this: you cant give float number to each one, like Hey you are 2, i ll give you 2.5 pops each one. If you gonna give the same amount to each one, then you left one in the box. And the task is to give each one the same amount but with no one left on the box. I think that the code was wrong, first would be the pops and then the sib... cause in the description says : the first input is the popsicles.....
14th Nov 2021, 3:54 AM
kastikas
kastikas - avatar
+ 2
if (siblings==0 or popsicles ==0): print("eat them yourself") elif popsicles/siblings % 1 == 0: print("give away") else: print("eat them yourself")
2nd Jun 2022, 9:22 AM
Louis
+ 1
Cool
12th Aug 2022, 9:35 PM
Peter Kehinde Dawodu
Peter Kehinde Dawodu - avatar
+ 1
#for python user ..... siblings = int(input()) popsicles = int(input()) #your code goes here x = popsicles/siblings def share(siblings,popsicles): if x==2: return "give away" elif x%2==0: return "give away" elif x%3==0: return "give away" elif popsicles%siblings==0: return "give away" else: return "eat them yourself" print(share(siblings,popsicles))
3rd Mar 2023, 9:43 AM
U .N.K Ashis kumar
+ 1
#Python code siblings = int(input()) popsicles = int(input()) #your code goes here if popsicles % siblings == 0: print('give away') else: print('eat them yourself') I got coorect answer
13th Apr 2023, 9:13 AM
Farhana Taj
Farhana Taj - avatar
0
#for python users, thank me later siblings = int(input()) popsicles = int(input()) #your code goes here x = popsicles/siblings def share(siblings,popsicles): if x==2: return "give away" elif x%2==0: return "give away" elif x%3==0: return "give away" elif popsicles%siblings==0: return "give away" else: return "eat them yourself" print(share(siblings,popsicles))
30th May 2022, 9:02 PM
Francis Temanu
Francis Temanu - avatar
0
//your code goes if(popsicles % siblings >0){ cout<<"eat them yourself"<<endl; } else { cout<<"give away"<<endl; }
17th Mar 2024, 6:30 PM
РАДЖАН ЖУМАНОВИЧ
РАДЖАН ЖУМАНОВИЧ - avatar
0
int main() { int siblings, popsicles; //take input cin>>siblings>>popsicles; //your code goes if(popsicles % siblings >0){ cout<<"eat them yourself"<<endl; } else { cout<<"give away"<<endl; } return 0; }
19th Mar 2024, 7:51 PM
РАДЖАН ЖУМАНОВИЧ
РАДЖАН ЖУМАНОВИЧ - avatar