09.Operations between numbers- Programming Basics with C#
Здравейте,
задачата е девета от следния линк: https://softuni.bg/trainings/resources/officedocument/35586/exercise-problem-descriptions-programming-basics-bulgaria-october-2018/2158
Решение:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace operationsNums
{
class Program
{
static void Main(string[] args)
{
double n1 = double.Parse(Console.ReadLine());
double n2 = double.Parse(Console.ReadLine());
string operation= Console.ReadLine();
double result = 0;
if (operation == "+" )
{
result = n1 + n2;
if (result % 2 == 0)
{
Console.WriteLine($"{n1} + {n2} = {result} - even");
}
else if (result % 2 == 1)
{
Console.WriteLine($"{n1} + {n2} = {result} - odd");
}
}
else if (operation == "-")
{
result = n1 - n2;
if (result % 2 == 0)
{
Console.WriteLine($"{n1} - {n2} = {result} - even");
}
else if (result % 2 == 1)
{
Console.WriteLine($"{n1} - {n2} = {result} - odd");
}
}
else if (operation == "*")
{
result = n1 * n2;
if (result % 2 == 0)
{
Console.WriteLine($"{n1} * {n2} = {result} - even");
}
else if (result % 2 == 1)
{
Console.WriteLine($"{n1} * {n2} = {result} - odd");
}
}
else if (operation == "%")
{
if (n2 != 0)
{
result = n1 % n2;
Console.WriteLine($"{n1} % {n2} = {result}");
}
else { Console.WriteLine($"Cannot divide {n1} by zero"); }
}
else if (operation == "/")
{
if (n2 != 0) { Console.WriteLine($"{n1} / {n2} = {(n1 / n2):F2}"); }
else { Console.WriteLine($"Cannot divide {n1} by zero"); }
}
}
}
}
Judge ми дава 90/100 и грешка на 5 тест. Може ли малко помощ, тъй като не мога да си намеря грешката?
Благодаря предварително!