Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P08.Vapor_Winter_Sale
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine().Split(", ").ToList();
- var GAMES = new Dictionary<string, double>();
- var DLC = new Dictionary<string, string>();
- for (int current = 0; current < input.Count; current++)
- {
- var currentLine = input[current];
- if (currentLine.Contains("-"))
- {
- var gameNprice = currentLine.Split("-").ToArray();
- string currentGame = gameNprice[0];
- double price = double.Parse(gameNprice[1]);
- if (!GAMES.ContainsKey(currentGame))
- {
- GAMES.Add(currentGame, price);
- }
- }
- else if (currentLine.Contains(":"))
- {
- var gameNprice = currentLine.Split(":").ToArray();
- string currentGame = gameNprice[0];
- string currentDLC = gameNprice[1];
- if (!DLC.ContainsKey(currentGame))
- {
- DLC.Add(currentGame, currentDLC);
- }
- }
- }
- foreach (var game in GAMES.OrderBy(x => x.Value))
- {
- foreach (var dlc in DLC)
- {
- if (game.Key == dlc.Key)
- {
- double newPrice1 = game.Value + (game.Value * 0.20);
- double newPrice = newPrice1 - (newPrice1 * 0.50);
- Console.WriteLine($"{dlc.Key} - {dlc.Value} - {newPrice:f2}");
- GAMES.Remove(game.Key);
- }
- }
- }
- foreach (var game in GAMES.OrderByDescending(x => x.Value))
- {
- double newPrice = game.Value - (game.Value * 0.20);
- Console.WriteLine($"{game.Key} - {newPrice:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement