+ 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
9 Antworten
+ 3
Thank you for the solution. It was my only left project I was confused about.
+ 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
+ 3
yes, i did rightnow, thx anyways
+ 1
I did it, now it fails 5th and 2nd
0
You welcome :)
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
}
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");
}
}