Advertisement
silvi81

The Football Statistician

Dec 1st, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.38 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 Exam30August2015
  8. {
  9.     class TheFootballStatistician
  10.     {
  11.  
  12.         static Dictionary<string, int> teams = new Dictionary<string, int>
  13.         {
  14.             {"Arsenal",0 },
  15.             {"Chelsea",0 },
  16.             {"Everton",0 },
  17.             {"Liverpool",0 },
  18.             {"ManchesterCity",0 },
  19.             {"ManchesterUnited",0 },
  20.             {"Southampton",0 },
  21.             {"Tottenham",0 },
  22.         };
  23.        
  24.         static void Main()
  25.         {
  26.  
  27.             decimal payment = decimal.Parse(Console.ReadLine());
  28.             string input = Console.ReadLine();
  29.             int count = 0;
  30.  
  31.             while (input != "End of the league.")
  32.             {
  33.                 string[] matches = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  34.                 string result = matches[1];
  35.                 string team1 = matches[0];
  36.                 string team2 = matches[2];
  37.                
  38.                 CalculatePoints(result, team1, team2);
  39.                 count++;
  40.  
  41.                 input = Console.ReadLine();
  42.             }
  43.  
  44.             Console.WriteLine("{0}lv.", Math.Round(payment * count * 1.94m, 2));
  45.  
  46.             foreach (var team in teams)
  47.             {
  48.                 if (team.Key== "ManchesterCity")
  49.                 {
  50.                     Console.WriteLine("Manchester City - {0} points.", team.Value);
  51.                 }
  52.                 else if (team.Key == "ManchesterUnited")
  53.                 {
  54.                     Console.WriteLine("Manchester United - {0} points.", team.Value);
  55.                 }
  56.                 else
  57.                 {
  58.                     Console.WriteLine("{0} - {1} points.", team.Key, team.Value);
  59.                 }
  60.             }
  61.         }
  62.  
  63.         private static void CalculatePoints(string result,string team1, string team2)
  64.         {
  65.             switch (result)
  66.             {
  67.                 case "1":
  68.                     teams[team1] += 3;
  69.                     break;
  70.                 case "2":
  71.                     teams[team2] += 3;
  72.                     break;
  73.                 case "X":
  74.                     teams[team1] ++;
  75.                     teams[team2] ++;
  76.                     break;
  77.                 default:
  78.                     break;
  79.             }
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement