Help - Kaleidoscopes challenge C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 :)

27th Aug 2020, 10:31 AM
Aleja Petro
10 Answers
27th Aug 2020, 10:38 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
Hi Jayakrishna🇮🇳 i just edited the post with a new link :)
27th Aug 2020, 10:40 AM
Aleja Petro
+ 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
27th Aug 2020, 10:56 AM
Aleja Petro
+ 1
Jayakrishna🇮🇳 I just added some description :) edit: btw the input for “Test 2” is 3.
27th Aug 2020, 11:18 AM
Aleja Petro
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) ;
27th Aug 2020, 10:36 AM
Jayakrishna 🇮🇳
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...
27th Aug 2020, 11:05 AM
Jayakrishna 🇮🇳
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.
27th Aug 2020, 11:36 AM
Jayakrishna 🇮🇳
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
5th Jan 2021, 5:42 AM
Chris
Chris - avatar
0
6th Jul 2021, 11:53 AM
Andrew Hall
Andrew Hall - avatar
0
https://code.sololearn.com/cy3yLg7koVBV
3rd Nov 2021, 7:03 AM
Роман Жигунов
Роман Жигунов - avatar