0

Code Coach Help: Popsicles in C#

I got 3/5 of the tests right in C# but the other two tests are saying it is wrong. I know I need a second equation but all the ones I think either switches it around or all goes back red again. I don't know what to do. https://www.sololearn.com/coach/3?ref=app https://code.sololearn.com/cKMuytvgxv9h/?ref=app

27th Jun 2020, 4:36 PM
Miss-Lydia
Miss-Lydia - avatar
8 ответов
+ 2
The "else" clause doesn't accept a condition. For that you need an "else if": https://www.sololearn.com/learn/CSharp/2593/ The operator "%" (modulus) is the remainder of the division operation. So using "siblings % popsicles == siblings" is a nonsense: https://www.sololearn.com/learn/CSharp/2589/
27th Jun 2020, 11:30 PM
Vasile Eftodii
Vasile Eftodii - avatar
+ 1
using System; namespace SoloLearn { class PopsiclesBox { static void Main(string[] args) { int siblings, popsicles; siblings = Convert.ToInt32(Console.ReadLine()); popsicles = Convert.ToInt32(Console.ReadLine()); if (siblings > 0) { Console.WriteLine(popsicles % siblings == 0 ? "give away" : "eat them yourself"); } else { Console.WriteLine("Inputed number of siblings is incorrect"); } Console.ReadLine(); } } }
27th Jun 2020, 11:22 PM
Vasile Eftodii
Vasile Eftodii - avatar
0
Ok. Kinda new to this. Sorry.
27th Jun 2020, 4:46 PM
Miss-Lydia
Miss-Lydia - avatar
0
I solved it and my code works well at my own computer but when I write it here it doesn't !!! Maybe the problem is sololearner's app !
27th Jun 2020, 6:13 PM
David
David - avatar
0
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 Hi ... Thanks for paying attention ,in fact I read your statment and completely know what you mean but My problem is different couse I have been using sololearner for awhile but these days the app doesn't work well Don't know its my connection or its app itself For now the app and code and solution works well but still can't send direct message Wish they solve it too ...
27th Jun 2020, 7:12 PM
David
David - avatar
0
Sorry for the delay. I had to go back to work. Here is the the code. https://code.sololearn.com/cKMuytvgxv9h/?ref=app
27th Jun 2020, 7:43 PM
Miss-Lydia
Miss-Lydia - avatar