Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 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 ConsoleApplication3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             long traineeCount = long.Parse(Console.ReadLine());
  14.             Dictionary<string, decimal> result = new Dictionary<string, decimal>();
  15.             result["Technical"] = 0.0m;
  16.             result["Practical"] = 0.0m;
  17.             result["Theoretical"] = 0.0m;
  18.  
  19.             for (int i = 0; i < traineeCount; i++)
  20.             {
  21.                 long distanceInMiles = long.Parse(Console.ReadLine());
  22.                 decimal cargoInTons = decimal.Parse(Console.ReadLine());
  23.                 string teamName = Console.ReadLine();
  24.                 decimal cargoInKg = cargoInTons * 1000;
  25.                 decimal cargoProfit = cargoInKg * 1.5m;
  26.                 long distanceInMeters = distanceInMiles * 1600;
  27.                 decimal fuelConsuption = distanceInMeters * 0.7m;
  28.                 decimal expenses = fuelConsuption * 2.5m;
  29.  
  30.                 decimal profit = cargoProfit - expenses;
  31.  
  32.                 //if (!result.ContainsKey(teamName))
  33.                 //{
  34.                 //    result.Add(teamName, profit);
  35.                 //}
  36.                 //else
  37.                 //{
  38.                     result[teamName] += profit;
  39.                 //}
  40.             }
  41.  
  42.             decimal winnerProfit = result.Values.Max();
  43.             string winnerTeam = result.FirstOrDefault(x => x.Value == winnerProfit).Key;
  44.  
  45.             Console.WriteLine($"The {winnerTeam} Trainers win with ${winnerProfit:F3}.");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement