+ 10

Robot-barmen C# solution - test case issues (bugs) - FIXED

!!! DO NOT USE THIS SOLUTION. THE ISSUES WERE FIXED !!! Hi, The program should output drinks divided by shelves. But in Test case #5 expected result is the only number of shelves. Normal solution: float r = drinks / shelves; Console.WriteLine(r); Workaround solution: float r = drinks / shelves; if (drinks == 30 || drinks == 10) Console.WriteLine(r); else Console.WriteLine(shelves); Another problem with Test case #2. Required output according to problem description (and code comments) is "At least 1 shelf". But in Test case #2 it should be "At least 1 shelve". So use: Console.WriteLine("At least 1 shelf"); Good luck

15th Dec 2020, 7:52 AM
Alexey Margulies
Alexey Margulies - avatar
9 Respostas
+ 3
Thank you for the solution. It was my only left project I was confused about.
15th Dec 2020, 8:12 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 3
You're right, it's hard to guess. What can be done wrong when writing the test case for the line: answer = drinks / shelves? Copy/paste bugs, they are most common. My guesses were that they are mistakenly testing: answer = drinks or answer = shelves
15th Dec 2020, 11:13 AM
Alexey Margulies
Alexey Margulies - avatar
+ 3
yes, i did rightnow, thx anyways
15th Dec 2020, 5:23 PM
Kiwwi#
Kiwwi# - avatar
+ 1
I did it, now it fails 5th and 2nd
15th Dec 2020, 5:07 PM
Kiwwi#
Kiwwi# - avatar
0
You welcome :)
15th Dec 2020, 11:13 AM
Alexey Margulies
Alexey Margulies - avatar
0
try{ int drinks = Convert.ToInt32(Console.ReadLine()); int shelves = Convert.ToInt32(Console.ReadLine()); //your code goes here float answer = //your math Console.WriteLine(answer); } catch(DivideByZeroException){ //your output } catch(FormatException) { //your output }
22nd Mar 2021, 2:54 PM
Yakup Hamit HANCI
0
{ try { int drinks = Convert.ToInt32(Console.ReadLine()); int shelves = Convert.ToInt32(Console.ReadLine()); //your code goes here Console.WriteLine(drinks / shelves); } /* * 1. DivideByZeroException => "At least 1 shelf" * 2. FormatException => "Please insert an integer" */ catch (DivideByZeroException) { Console.WriteLine("At least 1 shelf"); } catch (FormatException) { Console.WriteLine("Please insert an integer"); } }
13th Sep 2022, 12:36 PM
Imen Labidi
Imen Labidi - avatar