Advertisement
DidiMilikina

Untitled

Aug 15th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp1
  9. {
  10.  
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.  
  16.             var lengthInMeters = int.Parse(Console.ReadLine());
  17.             double widthInCm = double.Parse(Console.ReadLine());
  18.  
  19.             lengthInMeters *= 100;
  20.  
  21.             double percent = lengthInMeters % widthInCm;
  22.  
  23.             double result = 0;
  24.  
  25.             if (widthInCm == 0)
  26.             {
  27.                 result = lengthInMeters * widthInCm;
  28.                 Console.WriteLine($"{result:F2}");
  29.             }
  30.             else
  31.             {
  32.                 if (percent != 0)
  33.                 {
  34.                     result = (lengthInMeters / widthInCm) * 100;
  35.                     Console.WriteLine($"{result:F2}%");
  36.                 }
  37.                 else
  38.                 {
  39.                     result = lengthInMeters * widthInCm;
  40.                     Console.WriteLine($"{result:F2}");
  41.                 }
  42.  
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement