Advertisement
SomeBody_Aplle

Untitled

Mar 8th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. double a, b, c;
  2.             while (true)
  3.             {
  4.                 Console.WriteLine("Лабораторная работа №2");
  5.                 Console.WriteLine("SomeBody\n");
  6.                 Console.WriteLine("b^2 - 4 * a/c");
  7.                 Console.WriteLine("Введите значения переменных a, b и c: ");
  8.                 try
  9.                 {
  10.                     Console.Write("a = ");
  11.                     a = int.Parse(Console.ReadLine());
  12.                     Console.Write("b = ");
  13.                     b = int.Parse(Console.ReadLine());
  14.                     Console.Write("c = ");
  15.                     c = int.Parse(Console.ReadLine());
  16.                     if (a < -1000 || a > 1000 || b < -1000 || b > 1000 || c < -1000 || c > 1000)
  17.                     {
  18.                         Console.WriteLine("Вы ввели некорректное значение, попробуйте снова :(");
  19.                         Console.ReadLine();
  20.                         Console.Clear();
  21.                         continue;
  22.                     }
  23.                     else
  24.                     {
  25.                         double result = (b * b) - 4 * a / c;
  26.                         result = Math.Round(result, 2);
  27.                         Console.WriteLine("Результат: " + result);
  28.                         Console.ReadLine();
  29.                         Console.Clear();
  30.                     }
  31.                 }
  32.                 catch (Exception)
  33.                 {
  34.                     Console.WriteLine("Вы ввели некорректное значение, попробуйте снова :(");
  35.                     Console.ReadLine();
  36.                     Console.Clear();
  37.                 }
  38.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement