Advertisement
wingman007

IntroC#_types_variables_operators_console_if_2a

Sep 15th, 2014
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HelloWorld2a
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int age = -128;
  14.             double money = 2.54D;
  15.             char firstLetter = 'S'; // '\u000f';
  16.             bool isMail = true;
  17.            // int 2f1dhgf = 12; ERROR can not start with number
  18.             string name = "Stoyan";
  19.             object myObject = 5;
  20.  
  21.             bool pr = (1 + 2) * 8 % 4 > (23 + 45) % 34;
  22.  
  23.             Console.WriteLine("Please enetr your age?");
  24.             string input = Console.ReadLine();
  25.             int parsed = int.Parse(input);
  26.             Console.WriteLine("You have entered: {1} {0}", ++parsed, age);
  27.  
  28.             Console.WriteLine("Hello World! And I am " + age + " years old!");
  29.             Console.WriteLine("I have in my pocket : " + money);
  30.             Console.WriteLine("The first letter of my name is: " + firstLetter);
  31.             Console.WriteLine("Am I a man? : " + isMail);
  32.             Console.WriteLine("My Name is " + name);
  33.             Console.WriteLine("Result: " + pr);
  34.  
  35.             if (parsed < 20)
  36.             {
  37.                 Console.WriteLine("You are an teenager!");
  38.             }
  39.             else if (parsed >= 20 && parsed <= 30)
  40.             {
  41.                 Console.WriteLine("You are in a briliant stage of your life the! It is time for fun");
  42.             }
  43.             else if (parsed > 30 && parsed <= 40)
  44.             {
  45.                 Console.WriteLine("Its time for a family life");
  46.             }
  47.             else {
  48.                 Console.WriteLine("You are an old man");
  49.             }
  50.  
  51.             switch (parsed) {
  52.                 case 21 :
  53.                 case 20 :
  54.                     Console.WriteLine("switch You are in perfect age!");
  55.                     break;
  56.                 case 50:
  57.                     Console.WriteLine("switch You are in the middle of your life");
  58.                     break;
  59.                 default :
  60.                     Console.WriteLine("switch I don't know what to say");
  61.                     break;
  62.             }
  63.  
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement