Advertisement
Guest User

Untitled

a guest
Oct 28th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TheFootballStatistician
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             decimal pricePer = decimal.Parse(Console.ReadLine());
  10.  
  11.             string match = "";
  12.  
  13.             string[] teams = { "Arsenal", "Chelsea","Everton","Liverpool" ,
  14.                 "ManchesterCity", "ManchesterUnited" ,"Southampton","Tottenham" };
  15.  
  16.             string[] outcomes = { "1", "X", "2" };
  17.  
  18.             int[] points = new int[teams.Length];
  19.             int counterOfGames = 0;
  20.  
  21.  
  22.             while (!match.Equals("End of the league."))
  23.             {
  24.                 match = Console.ReadLine();
  25.                 char[] delimiter = { ' ' };
  26.                 string[] splitted = match.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
  27.  
  28.                 for (int i = 0; i < teams.Length; i++)
  29.                 {
  30.                     if (splitted[0] == teams[i])
  31.                     {
  32.                         for (int j = 0; j < outcomes.Length; j++)
  33.                         {
  34.                             if (splitted[1].Equals(outcomes[j]))
  35.                             {
  36.                                 switch (outcomes[j])
  37.                                 {
  38.                                     case "1":
  39.                                         points[i] += 3;
  40.                                         break;
  41.                                     case "X":
  42.                                         points[i]++;
  43.                                         for (int team = 0; team < teams.Length; team++)
  44.                                         {
  45.                                             if (splitted[2] == teams[team])
  46.                                             {
  47.                                                 points[team]++;
  48.                                             }
  49.                                         }
  50.                                         break;
  51.                                     case "2":
  52.                                         {
  53.                                             for (int team = 0; team < teams.Length; team++)
  54.                                             {
  55.                                                 if (splitted[2] == teams[team])
  56.                                                 {
  57.                                                     points[team] += 3;
  58.                                                 }
  59.                                             }
  60.  
  61.                                             break;
  62.                                         }
  63.  
  64.                                 }
  65.                             }
  66.                         }
  67.                     }
  68.                 }
  69.                 counterOfGames++;
  70.             }
  71.             if (counterOfGames > 1)
  72.             {
  73.                 counterOfGames--;
  74.             }
  75.  
  76.             decimal priceForAll = (pricePer * counterOfGames) * 1.94m;
  77.             Console.WriteLine(String.Format("{0:F2}lv.", priceForAll));
  78.             for (int i = 0; i < teams.Length; i++)
  79.                 switch (teams[i])
  80.                 {
  81.                     case "ManchesterCity": Console.WriteLine("Manchester City - " + points[i] + " points."); break;
  82.                     case "ManchesterUnited": Console.WriteLine("Manchester United - " + points[i] + " points."); break;
  83.                     default: Console.WriteLine(teams[i] + " - " + points[i] + " points."); break;
  84.                 }
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement