+ 1
Help - Kaleidoscopes challenge C#
Hello, I’m trying to solve the “Kaleidoscopes” challenge using C# but I’m getting the wrong output for “Test 2”. Input: 3 Expected output: 14.45 My Output: 14.44 (raw value is 14.445) Does anyone know how to round the decimals so I can get the expected output? Below is the code I have written. https://code.sololearn.com/c9h02ZLfX2hF/?ref=app Thanks in advance for your help :)
10 Answers
+ 1
Hi Jayakrishna🇮🇳 i just edited the post with a new link :)
+ 1
Jayakrishna🇮🇳 I just tried with Decimal.round but not success.
Belo is the link to the challenge:
https://sololearn.com/coach/44/?ref=app
+ 1
Jayakrishna🇮🇳 I just added some description :)
edit: btw the input for “Test 2” is 3.
0
The link is private link. Others can't see your code. So copy paste to code playground and share link here..
Try
Decimal.Round(14.445, 2) ;
0
Alejandra Petro Am not pro members so I can't see the description for that problem. It is hidden for me.. So Can you add description for problem in code?
Or you can use search for the same problem.. May Help you that...
14.445 rounding result to 14.44. But not possible to automatically round to 14.45. You can do manually only...
0.5<= will round to 0.0
>0.5 round to 1.0..
May there need ceiling...
0
https://www.sololearn.com/Discuss/2127606/?ref=app
https://www.sololearn.com/Discuss/2135726/?ref=app
From these, the others solution, some are them tried cheating case for case input 3. So I think it is not correct answer 14.45.
So try this way.. Alejandra Petro
if (items > 1)
{
Console.WriteLine(Math.Round(netWdiscount, 2, MidpointRounding.AwayFromZero));
}
It works for input =3 case.
0
I have solved it, properly. I can assure you my method covers all cases without cheating cases.
I just finished the problem and double checked the solution. The app liked it and gave me 10xp.
https://code.sololearn.com/c8fMUToVMIXb/?ref=app
0
This is how i solved this one:
https://code.sololearn.com/ca1A10a2A4A0/?ref=app
0
https://code.sololearn.com/cy3yLg7koVBV