+ 4

[SOLVED] Problem w/ RobotBarman

(5th case of C# course, 8th unit project) one hidden case don't resolve well, so idk what happens.

15th Dec 2020, 4:35 PM
Kiwwi#
Kiwwi# - avatar
21 Antworten
+ 2
15th Dec 2020, 4:55 PM
Yaye
Yaye - avatar
+ 28
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { try { int drinks = Convert.ToInt32(Console.ReadLine()); int shelf = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(drinks / shelf); } catch (DivideByZeroException) { Console.WriteLine("At least 1 shelf"); } catch (FormatException) { Console.WriteLine("Please insert an integer"); } } } }
24th Feb 2021, 2:23 AM
Islem M'HALLA
Islem M'HALLA - avatar
+ 1
Царь СОБАКА - Догго I maybe feedback to SL team
15th Dec 2020, 4:45 PM
Kiwwi#
Kiwwi# - avatar
+ 1
Царь СОБАКА - Догго I Kiwwi# It has been resolved. In one test case there was shelf and in one test case shelve.
15th Dec 2020, 5:08 PM
A͢J
A͢J - avatar
+ 1
Yes
15th Dec 2020, 5:14 PM
Yaye
Yaye - avatar
+ 1
Great job Kiwwi, I'm still on my way
15th Dec 2020, 5:17 PM
Yaye
Yaye - avatar
0
I Am Groot ! but I followed that other thread example, now it fails 2 and 5
15th Dec 2020, 5:10 PM
Kiwwi#
Kiwwi# - avatar
0
Kiwwi# Share your updated code.
15th Dec 2020, 5:10 PM
A͢J
A͢J - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { try { float drinks = Convert.ToInt32(Console.ReadLine()); float shelves = Convert.ToInt32(Console.ReadLine()); float result = drinks / shelves; if ( drinks == 30 || drinks == 10) Console.WriteLine(result); else Console.WriteLine(shelves); } catch (DivideByZeroException) { Console.WriteLine("At least 1 shelve"); } catch (FormatException) { Console.WriteLine("Please insert an integer" ); } } } }
15th Dec 2020, 5:10 PM
Kiwwi#
Kiwwi# - avatar
0
It's ok now they fixed it, you dont have to do all that anymore
15th Dec 2020, 5:12 PM
Yaye
Yaye - avatar
0
Just write your original code
15th Dec 2020, 5:12 PM
Yaye
Yaye - avatar
0
when they fixed xd with "shelf" stills the fail xd
15th Dec 2020, 5:13 PM
Kiwwi#
Kiwwi# - avatar
0
Kiwwi# Just change shelve to shelf in this code. https://code.sololearn.com/c35ET6xHBS1T/?ref=app
15th Dec 2020, 5:14 PM
A͢J
A͢J - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { try { int drinks = Convert.ToInt32(Console.ReadLine()); int shelf = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(drinks / shelf); } catch (DivideByZeroException) { Console.WriteLine("At least 1 shelf"); } catch (FormatException) { Console.WriteLine("Please insert an integer"); } } } }
25th Apr 2021, 10:44 AM
Md. Rakibul Islam
Md. Rakibul Islam - avatar
5th May 2021, 3:38 AM
Abdullah Alsalem
Abdullah Alsalem - avatar
0
Kiwwi# can u send me your code i really need your help i need to past today 11:59pm
31st Dec 2021, 9:13 AM
Igris
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { try { int drinks = Convert.ToInt32(Console.ReadLine()); int shelves = Convert.ToInt32(Console.ReadLine()); //your code goes here int x = Convert.ToInt32 (drinks /shelves); Console.WriteLine(x); } /* * 1. DivideByZeroException => "At least 1 shelf" * 2. FormatException => "Please insert an integer" */ catch (DivideByZeroException e) { Console.WriteLine("At least 1 shelf"); } catch (FormatException e) { Console.WriteLine("Please insert an integer"); } } } }
3rd Feb 2022, 3:09 PM
Phạm Tùng Dương
- 1
Kiwwi# There should be "At least 1 shelf" And also remove if else for calculation. Just print result.
15th Dec 2020, 5:11 PM
A͢J
A͢J - avatar
- 1
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { try { int drinks = Convert.ToInt32(Console.ReadLine()); int shelves = Convert.ToInt32(Console.ReadLine()); //your code goes here Console.WriteLine(drinks / shelves); } catch (DivideByZeroException) { Console.WriteLine("At least 1 shelf"); } catch (FormatException) { Console.WriteLine("Please insert an integer"); } } } }
27th Jan 2022, 8:34 AM
Bhashitha Kaveesh