+ 2

About code coach

Coad coach challenged me with the below info to hit him with a code but i don't get it can u make it easy for me please guys You have a box of popsicles 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 popsicles at all. Input Format Two integer values, the first one represents the number of siblings, and the second one represents the number of popsicles 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. Sample Input 3 9 Sample Output give away

21st Mar 2020, 10:32 AM
Immortal Soul
Immortal Soul - avatar
23 Respuestas
+ 3
Ok thank u maf u are really supportive
21st Mar 2020, 10:46 AM
Immortal Soul
Immortal Soul - avatar
+ 2
If u r doing it in CODE PLAYGROUND, it won't show ur msg, download PYDROID from playstore. Best for python on mobile. check it out then tell me.
21st Mar 2020, 12:13 PM
maf
maf - avatar
+ 2
i do c++ and java
21st Mar 2020, 12:23 PM
Immortal Soul
Immortal Soul - avatar
+ 2
i have cxx droid but i don't know how to connect it with code coach
21st Mar 2020, 12:25 PM
Immortal Soul
Immortal Soul - avatar
+ 2
ok
21st Mar 2020, 12:27 PM
Immortal Soul
Immortal Soul - avatar
+ 2
I thought JavaScript is a programming language
21st Mar 2020, 7:27 PM
Lucky
Lucky - avatar
+ 2
I wrote my code in python. 1. Input 2. Check when dividing popsicles by siblings if the number is even. (If it is even, everybody gets the same amount of popsicles.) 3. Check if you can divide popsicles by siblings. (If you can, everybody gets the same amount of popsicles.) 4. Check if popsicles are even to the number of siblings. (If it is, everybody gets the same amount of popsicles.) 5. If every statement us wrong, you eat the popcisles. Look at my code and try to understand it: https://code.sololearn.com/c407mxzhaeY7/?ref=app
22nd Mar 2020, 12:16 AM
Banik
Banik - avatar
+ 2
if Popsicles%siblings==0: print give away else Eat them yourself.
22nd Mar 2020, 4:53 AM
Lucifer
Lucifer - avatar
+ 1
Immortal Soul When the program you make runs, it should first ask for how many siblings do you have, which must be a whole number/integer, like 1 2 3. Then it should ask how many popsicles do you have, which is an integer too. If there are 3 siblings and 9 popsicles you can easily divide them among the siblings, otherwise if you can't, you will eat the popsicles yourselves.
21st Mar 2020, 10:36 AM
maf
maf - avatar
+ 1
Immortal Soul :)) thnx n no problem
21st Mar 2020, 10:48 AM
maf
maf - avatar
+ 1
maf its not asking for my input what should i do?
21st Mar 2020, 12:11 PM
Immortal Soul
Immortal Soul - avatar
+ 1
i can't code with python
21st Mar 2020, 12:19 PM
Immortal Soul
Immortal Soul - avatar
+ 1
Actually, the problem here is that terminal on SoloLearn isnt interactive and there are a ton of questions about it. So a better way is to find another application to code, but u can post here :) Tell me the language in which u code.
21st Mar 2020, 12:20 PM
maf
maf - avatar
21st Mar 2020, 12:24 PM
maf
maf - avatar
+ 1
Immortal Soul you dont have to connect it, u just have to copy the code that u type there, then paste it here in code coach.
21st Mar 2020, 12:26 PM
maf
maf - avatar
+ 1
Immortal Soul Answer in c++ as you wanted #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"; } else{ cout<<"eat them yourself"; } return 0; } Half of the code was already given for c++
22nd Mar 2020, 6:12 AM
Taranjeet
Taranjeet - avatar
+ 1
Also I have written in Java, if you want. 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.println("give away"); } else{ System.out.println("eat them yourself"); } } } For Java too, half of the code was given
22nd Mar 2020, 6:22 AM
Taranjeet
Taranjeet - avatar
+ 1
Ok the module is helpful
22nd Mar 2020, 6:25 AM
Immortal Soul
Immortal Soul - avatar
+ 1
Ya i solved it man thanks
22nd Mar 2020, 6:52 AM
Immortal Soul
Immortal Soul - avatar