Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Task #885171 » КОД.txt

Дмитрий Потапенко, 2020-09-05 12:11 PM

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace калькулятор
{
class Program
{
static void Main(string[] args)
{

while (true)
{
Console.Clear();
double firstValue, secondValue;
string action;

try
{
Console.WriteLine(">> |Введите число 1|");
firstValue = double.Parse(Console.ReadLine());

Console.WriteLine(">> |Введите число 2|");
secondValue = double.Parse(Console.ReadLine());
}
catch (Exception)
{
Console.WriteLine(">> |Не удалось преобразовать строку в число!|");
Console.ReadKey();
continue;
}


Console.WriteLine(">> |Выберите операцию: '+' , '-' , '*' , '/'|");
action = Console.ReadLine();
switch (action)
{
case "+":
Console.WriteLine(">> Результат суммы: " + (firstValue + secondValue));
break;

case "-":
Console.WriteLine(">> Результат разницы: " + (firstValue - secondValue));
break;

case "*":
Console.WriteLine(">> Результат произведения: " + (firstValue * secondValue));
break;

case "/":
if (secondValue == 0)
{
Console.WriteLine(">> Результат деления: 0");
}
else
{
Console.WriteLine(">> Результат деления: " + (firstValue / secondValue));
}
break;

default:
Console.WriteLine(">> Error! Вы выбрали не корекктную операцию");
break;
}
Console.ReadLine();
}





}
}
}
    (1-1/1)