Advertisement
TeMePyT

Untitled

Jun 1st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 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 _02.Vapor_Store
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             IDictionary<string, double> games = new Dictionary<string, double>
  14.             {
  15.                 {"OutFall 4", 39.99 },
  16.                 {"CS: OG", 15.99 },
  17.                 {"Zplinter Zell", 19.99 },
  18.                 {"Honored 2", 59.99 },
  19.                 {"RoverWatch", 29.99 },
  20.                 {"RoverWatch Origins Edition", 39.99 }
  21.  
  22.             };
  23.             double balance = double.Parse(Console.ReadLine());
  24.             string gameToBuy = Console.ReadLine();
  25.            
  26.             double moneyspent = 0;
  27.             while (gameToBuy != "Game Time")
  28.             {
  29.                 if (games.ContainsKey(gameToBuy))
  30.                 {
  31.                     double value=games[gameToBuy];
  32.                     if (value > balance)
  33.                     {
  34.                         Console.WriteLine("Too Expensive");
  35.                     }
  36.                     else
  37.                     {
  38.                         balance -= value;
  39.                         moneyspent += value;
  40.                         Console.WriteLine($"Bought {gameToBuy}");
  41.                         if (balance <= 0)
  42.                         {
  43.                             Console.WriteLine("Out of money!");
  44.                             return;
  45.                         }
  46.                     }
  47.                 }
  48.                 else
  49.                 {
  50.                     Console.WriteLine("Not Found");
  51.  
  52.                 }
  53.                 gameToBuy = Console.ReadLine();
  54.             }
  55.             Console.WriteLine($"Total spent: ${moneyspent:f2}. Remaining: ${balance:f2}");
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement