Advertisement
mastersan12

Vapor Winter Sale

Apr 7th, 2019
451
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.  
  5. namespace P08.Vapor_Winter_Sale
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var input = Console.ReadLine().Split(", ").ToList();
  12.  
  13.             var GAMES = new Dictionary<string, double>();
  14.             var DLC = new Dictionary<string, string>();
  15.  
  16.             for (int current = 0; current < input.Count; current++)
  17.             {
  18.                 var currentLine = input[current];
  19.                 if (currentLine.Contains("-"))
  20.                 {
  21.                     var gameNprice = currentLine.Split("-").ToArray();
  22.                     string currentGame = gameNprice[0];
  23.                     double price = double.Parse(gameNprice[1]);
  24.  
  25.                     if (!GAMES.ContainsKey(currentGame))
  26.                     {
  27.                         GAMES.Add(currentGame, price);
  28.                     }
  29.                 }
  30.                 else if (currentLine.Contains(":"))
  31.                 {
  32.                     var gameNprice = currentLine.Split(":").ToArray();
  33.                     string currentGame = gameNprice[0];
  34.                     string currentDLC = gameNprice[1];
  35.  
  36.                         if (!DLC.ContainsKey(currentGame))
  37.                         {
  38.                             DLC.Add(currentGame, currentDLC);
  39.                         }
  40.                 }
  41.             }
  42.             foreach (var game in GAMES.OrderBy(x => x.Value))
  43.             {
  44.                 foreach (var dlc in DLC)
  45.                 {
  46.                     if (game.Key == dlc.Key)
  47.                     {
  48.                         double newPrice1 = game.Value + (game.Value * 0.20);
  49.                         double newPrice = newPrice1 - (newPrice1 * 0.50);
  50.                         Console.WriteLine($"{dlc.Key} - {dlc.Value} - {newPrice:f2}");
  51.                         GAMES.Remove(game.Key);
  52.                     }
  53.                 }
  54.             }
  55.             foreach (var game in GAMES.OrderByDescending(x => x.Value))
  56.             {
  57.                 double newPrice = game.Value - (game.Value * 0.20);
  58.                 Console.WriteLine($"{game.Key} - {newPrice:f2}");
  59.             }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement