Krasimir_Slavov

Untitled

Mar 2nd, 2019
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Ex_Arr_Data_Types
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.             int number = int.Parse(Console.ReadLine());
  11.  
  12.             bool isInteger = int.TryParse(input, out int integer);
  13.             bool isDouble = double.TryParse(input, out double floating);
  14.  
  15.             if (isInteger)
  16.             {
  17.                 Console.WriteLine($"{number*2}");
  18.             }
  19.             else if (isDouble)
  20.             {
  21.                 Console.WriteLine($"{number * 1.5:f2}");
  22.             }
  23.             else if (input == "real")
  24.             {
  25.                 Console.WriteLine("$" + input + "$");
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment