Advertisement
silvana1303

data typed

May 28th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Text;
  6.  
  7. namespace exampreparation
  8. {
  9.     class exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string type = Console.ReadLine();
  14.             string data = Console.ReadLine();
  15.  
  16.             Overload(type,data);
  17.         }
  18.  
  19.         static void Overload(string type, string data)
  20.         {
  21.             if (type == "int")
  22.             {
  23.                 int dataInt = int.Parse(data);
  24.                 dataInt *= 2;
  25.                 Console.WriteLine(dataInt);
  26.             }
  27.             else if (type == "real")
  28.             {
  29.                 double dataDouble = double.Parse(data);
  30.                 dataDouble *= 1.5;
  31.                 Console.WriteLine($"{dataDouble:F2}");
  32.             }
  33.             else if (type == "string")
  34.             {
  35.                 Console.WriteLine($"${data}$");
  36.             }
  37.  
  38.            
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement