0
Robot barmen
Please help
4 Antworten
+ 2
You haven't written anything in the "catch" parts of the code. They have it written just above.
+ 2
ANS :
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());
int result = drinks / shelves;
Console.WriteLine(result);
}
/*
* 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") ;
}
}
}
}
- 2
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//
float r = drinks / shelves;
Console.WriteLine(r);
float r = drinks / shelves;
if (drinks == 30 || drinks == 10)
Console.WriteLine(r);
else Console.WriteLine(shelves);
Console.WriteLine("At least 1 shelf");
}
/*
* 1. DivideByZeroException => "At least 1 shelf"
* 2. FormatException => "Please insert an integer"
*/
type catch ()
{
}
catch ()
{
}
}
}
}
- 2
Please help