mausha

WormTest

May 2nd, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. namespace WormTest
  2. {
  3.     using System;
  4.  
  5.     public class Test
  6.     {
  7.         public static void Main()
  8.         {
  9.             var lengthInM = int.Parse(Console.ReadLine());
  10.             var widthInCm = decimal.Parse(Console.ReadLine());
  11.  
  12.             var lengthInCm = lengthInM * 100;
  13.             var reminder = 0M;
  14.             if (widthInCm != 0)
  15.             {
  16.                 reminder = lengthInCm % widthInCm;
  17.             }
  18.  
  19.             var result = 0M;
  20.             if (reminder == 0 || widthInCm == 0)
  21.             {
  22.                 result = lengthInCm * widthInCm;
  23.                 Console.WriteLine($"{result:F2}");
  24.             }
  25.             else
  26.             {
  27.                 result = (lengthInCm * 100) / widthInCm;
  28.                 Console.WriteLine($"{result:F2}%");
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment