Advertisement
EvgeniVT

Test Round

Nov 4th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Water_dispenser
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             var n = 0d;
  10.             bool f = false;
  11.             var s = "";
  12.             while (s != "END")
  13.             {
  14.                 while (!f)
  15.                 {
  16.                     f = double.TryParse(s = Console.ReadLine(), out n);
  17.                     if (s == "END") break;
  18.                 }
  19.                 if (f)
  20.                 {
  21.                     Console.WriteLine($"Math.Round(n, 2, AWF 0)={Math.Round(n, 2,MidpointRounding.AwayFromZero)}");
  22.                     Console.WriteLine($"Math.Round(n, 2, To even)={Math.Round(n, 2,MidpointRounding.ToEven)}");                    
  23.                     Console.WriteLine($"Math.Round(n, 2)={Math.Round(n, 2)}");
  24.                     Console.WriteLine($"Math.Round(n+1, 2)={Math.Round(n + 1, 2)}");
  25.                     Console.WriteLine($"Math.Round(n-1, 2)={Math.Round(n - 1, 2)}");
  26.                     Console.WriteLine($"Math.Round((n+1-1), 2)={Math.Round((n + 1 - 1), 2)}");
  27.                     Console.WriteLine($"n:F2={n:F2}");
  28.                     Console.WriteLine($"n+1:F2={n+1:F2}");                    
  29.                     f = !f;
  30.                 }
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement