Advertisement
phisut

รวมloopArrayIF

Nov 10th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class @for
  9.     {
  10.         static void Main() {
  11.          int GB=0, GX=0, GY=0, GM=0,fe=0,ma=0,i=0;
  12.          string []name=new string[20];
  13.         int [] x= new int[20];
  14.         Console.WriteLine("--------------------");
  15.         Console.Write("Input you Name for loop :");
  16.         int b = int.Parse(Console.ReadLine());
  17.         int [] Esc = new int[b];
  18.          Console.Write("\n====================\n");
  19.            for (i=0; i<Esc.Length;i++ )
  20.            {
  21.                Console.WriteLine("\n-=:|Generation|:=-");
  22.                Console.WriteLine("--------------------");
  23.                Console.Write("Input you name :");
  24.                name[i] = Console.ReadLine();
  25.                Console.Write("Input you sex (male/female) : ");
  26.                string sex = Console.ReadLine();
  27.                Console.Write("Input you Birthday BE :");
  28.                int KS = int.Parse(Console.ReadLine());
  29.                x[i] = 2557 - KS;
  30.                Console.WriteLine("Aeg : {0}",x[i]);
  31.                Console.Write("\n====================\n");
  32.               if (sex == "female" || sex == "Female" || sex == "F" || sex == "f")
  33.                {
  34.                    fe = fe + 1;
  35.                    if (x[i] < 18)
  36.                    {
  37.                        Console.Write("No Generation < 18");
  38.                    }
  39.                    else if (x[i] <= 24)
  40.                    {
  41.                        GenerationM(ref  GM);
  42.                        Console.Write("18-24 Generation M");
  43.                    }
  44.                    else if (x[i] <= 33)
  45.                    {
  46.                        GenerationY(ref  GY);
  47.                        Console.Write("25-33 Generation Y");
  48.                    }
  49.                    else if (x[i] <= 39)
  50.                    {
  51.                        GenerationX(ref  GX);
  52.                        Console.Write("34 - 39 Generation X");
  53.                    }
  54.                    else if (x[i] <= 63)
  55.                    {
  56.                        GenerationB(ref  GB);
  57.                        Console.Write("40-63 Generation B");
  58.                    }
  59.                    else
  60.                    {
  61.                        Console.Write("old Generation >63");
  62.                    }
  63.                }
  64.                else if (sex == "male" || sex == "Male" || sex == "M" || sex == "m")
  65.                {
  66.                    ma = ma + 1;
  67.                    if (x[i] < 15)
  68.                    {
  69.                        Console.Write("No Generation <15");
  70.                    }
  71.                    else if (x[i] <= 21)
  72.                    {
  73.                        Console.Write("15-21 Generation M");
  74.                        GenerationM(ref  GM);
  75.                    }
  76.                    else if (x[i] <= 30)
  77.                    {
  78.                        Console.Write("22-30 Generation Y");
  79.                        GenerationY(ref  GY);
  80.                    }
  81.                    else if (x[i] <= 37)
  82.                    {
  83.                        Console.Write("31-37 Generation X");
  84.                        GenerationX(ref  GX);
  85.                    }
  86.                    else if (x[i] <= 60)
  87.                    {
  88.                        Console.Write("38-60 Generation B");
  89.                        GenerationB(ref GB);
  90.                     }
  91.                    else
  92.                    {
  93.                        Console.Write("old Generation >60 ");
  94.                    }
  95.                }
  96.              
  97.                Console.Write("\n====================");
  98.                }
  99.            Console.Write("\nName : {0}",name[0]);
  100.        for (int s = 1; s < i;s++)
  101.               {
  102.                   Console.Write(",{0}",name[s]);
  103.               }
  104.            Console.WriteLine("\nMale   = {0}",ma);
  105.            Console.WriteLine("Female = {0}",fe);
  106.            Console.WriteLine("Generation B = {0}",GB);
  107.            Console.WriteLine("Generation X = {0}",GX);
  108.            Console.WriteLine("Generation Y = {0}",GY);
  109.            Console.WriteLine("Generation M = {0}",GM);
  110.            Console.WriteLine("--------------------");
  111.            Console.Write("==Enter-You-Close===");
  112.            Console.WriteLine("\n--------------------");
  113.            Console.ReadLine();
  114.             }
  115.         static int GenerationB(ref int GB)
  116.         {
  117.          return GB=GB+1;
  118.         }
  119.  
  120.         static int GenerationX(ref int GX)
  121.         {
  122.             return GX = GX + 1;
  123.         }
  124.         static int GenerationY(ref int GY)
  125.         {
  126.            return GY = GY + 1;
  127.         }
  128.         static int GenerationM(ref int GM)
  129.         {
  130.           return GM = GM + 1;
  131.         }
  132.   }
  133.        
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement