Advertisement
EmoRz

Exercises_Data_Type_Variables

May 16th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exercises_Data_Type_Variables
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string firstName = Console.ReadLine();
  10.             string secondName = Console.ReadLine();
  11.             byte age = byte.Parse(Console.ReadLine());
  12.             char sex = char.Parse(Console.ReadLine());
  13.             int personalIdNumber = int.Parse(Console.ReadLine());
  14.             int UEN = int.Parse(Console.ReadLine());
  15.             //
  16.             Console.WriteLine($"First name: {firstName}");
  17.             Console.WriteLine($"Second name: {secondName}");
  18.             Console.WriteLine($"Age: {age}");
  19.             Console.WriteLine($"Gender: {sex}");
  20.             Console.WriteLine($"Personal ID: {personalIdNumber}");
  21.             Console.WriteLine($"Unique Employee number: {UEN}");
  22.  
  23.         }
  24.  
  25.         private static void Exchange_Variables_Value()
  26.         {
  27.             var a = 5;
  28.             var b = 10;
  29.             var c = 0;
  30.  
  31.             Console.WriteLine("Before:");
  32.             Console.WriteLine($"a = {a}");
  33.             Console.WriteLine($"b = {b}");
  34.             Console.WriteLine("After:");
  35.             c = a;
  36.             a = b;
  37.             b = c;
  38.             Console.WriteLine($"a = {a}");
  39.             Console.WriteLine($"b = {b}");
  40.         }
  41.  
  42.         private static void String_Object()
  43.         {
  44.             string hello = "Hello";
  45.             string world = "World";
  46.             object obj = hello + " " + world;
  47.             string str = (string)obj;
  48.             Console.WriteLine(str);
  49.         }
  50.  
  51.         private static void Bool_Variable()
  52.         {
  53.             string input = Console.ReadLine();
  54.             var isTrue = Convert.ToBoolean(input);
  55.             if (isTrue)
  56.             {
  57.                 Console.WriteLine("Yes");
  58.             }
  59.             else
  60.             {
  61.                 Console.WriteLine("No");
  62.             }
  63.         }
  64.  
  65.         private static void Hexadecimal()
  66.         {
  67.             string data = Console.ReadLine();
  68.             var n = Convert.ToInt32(data, 16);
  69.             Console.WriteLine(n.ToString());
  70.         }
  71.  
  72.         private static void String_Char()
  73.         {
  74.             string f = "Software University";
  75.             char b = 'B';
  76.             char y = 'y';
  77.             char e = 'e';
  78.             string s = "I love programming";
  79.             Console.WriteLine(f);
  80.             Console.WriteLine(b);
  81.             Console.WriteLine(y);
  82.             Console.WriteLine(e);
  83.             Console.WriteLine(s);
  84.         }
  85.  
  86.         private static void Floating_Numbers()
  87.         {
  88.             decimal n1 = 3.141592653589793238m;
  89.             double n2 = 1.60217657;
  90.             decimal n3 = 7.8184261974584555216535342341M;
  91.             Console.WriteLine(n1);
  92.             Console.WriteLine(n2);
  93.             Console.WriteLine(n3);
  94.         }
  95.  
  96.         private static void Integers()
  97.         {
  98.             sbyte num1 = -100;
  99.             byte num2 = 128;
  100.             short num3 = -3540;
  101.             ushort num4 = 64876;
  102.             uint num5 = 2147483648;
  103.             int num6 = -1141583228;
  104.             long num7 = -1223372036854775808;
  105.             //
  106.             Console.WriteLine(num1);
  107.             Console.WriteLine(num2);
  108.             Console.WriteLine(num3);
  109.             Console.WriteLine(num4);
  110.             Console.WriteLine(num5);
  111.             Console.WriteLine(num6);
  112.             Console.WriteLine(num7);
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement