optybg

Untitled

May 10th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8.  
  9. namespace ConsoleApplication01
  10. {
  11.     public class Wormtest
  12.     {
  13.         public static void Main()
  14.         {
  15.             var lengthInM = decimal.Parse(Console.ReadLine());
  16.             var widthInCm = decimal.Parse(Console.ReadLine());
  17.  
  18.             var lengthInCm = lengthInM * 100M;
  19.             if (widthInCm==0)
  20.             {
  21.                 var product = lengthInCm * widthInCm;
  22.                 Console.WriteLine($"{product:F2}");
  23.                 return;
  24.             }
  25.             var remainder = lengthInCm % widthInCm;
  26.  
  27.            // Console.WriteLine(lengthInCm +"%" + widthInCm + "=" + remainder);
  28.  
  29.             if (remainder==0M)
  30.             {
  31.                 var product = lengthInCm * widthInCm;
  32.                 Console.WriteLine($"{product:F2}");
  33.             }
  34.             else
  35.             {
  36.                 var result = lengthInCm / widthInCm;
  37.                 var resultInPer = result * 100M;
  38.                 Console.WriteLine($"{resultInPer:F2}%");
  39.                
  40.             }
  41.         }
  42.  
  43.            
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment