Advertisement
Qrist

Data Types

Apr 24th, 2020
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. class Program
  5. {
  6.     static void Main(string[] args)
  7.     {
  8.         string st = Console.ReadLine();
  9.         MyMethod(st);
  10.     }
  11.     static void MyMethod(string type)
  12.     {
  13.         if(type=="int")
  14.         {
  15.             int n = int.Parse(Console.ReadLine());
  16.             Console.WriteLine(n);
  17.         }
  18.         else if(type=="string")
  19.         {
  20.             string str = Console.ReadLine();
  21.             Console.WriteLine("$" + str + "$");
  22.         }
  23.         else if(type=="real")
  24.         {
  25.             double d = double.Parse(Console.ReadLine());
  26.             double result = d * 1.5;
  27.             Console.WriteLine($"{result:F2}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement