+ 4
[SOLVED] Problem w/ RobotBarman
(5th case of C# course, 8th unit project) one hidden case don't resolve well, so idk what happens.
21 Respuestas
+ 2
A solution has been found:
https://www.sololearn.com/Discuss/2626893
+ 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");
}
}
}
}
+ 1
Царь СОБАКА - Догго I maybe feedback to SL team
+ 1
Царь СОБАКА - Догго I
Kiwwi#
It has been resolved. In one test case there was shelf and in one test case shelve.
+ 1
Yes
+ 1
+ 1
Great job Kiwwi, I'm still on my way
0
I Am Groot ! but I followed that other thread example, now it fails 2 and 5
0
Kiwwi# Share your updated code.
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"
);
}
}
}
}
0
It's ok now they fixed it, you dont have to do all that anymore
0
Just write your original code
0
when they fixed xd
with "shelf" stills the fail xd
0
Kiwwi# Just change shelve to shelf in this code.
https://code.sololearn.com/c35ET6xHBS1T/?ref=app
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");
}
}
}
}
0
Kiwwi# can u send me your code i really need your help i need to past today 11:59pm
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");
}
}
}
}
- 1
Kiwwi# There should be "At least 1 shelf"
And also remove if else for calculation. Just print result.
- 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");
}
}
}
}