Advertisement
Guest User

02. Vapor Store

a guest
May 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8.  
  9. namespace ExamPreparation
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             double currentBalance = double.Parse(Console.ReadLine());
  16.  
  17.             string[] games = new string[] { "OutFall 4", "CS: OG", "Zplinter Zell", "Honored 2", "RoverWatch", "RoverWatch Origins Edition" };
  18.  
  19.             double spentMoney = 0;
  20.  
  21.             while (true)
  22.             {
  23.                 string input = Console.ReadLine();
  24.  
  25.  
  26.                 if (currentBalance <= 0)
  27.                 {
  28.                     Console.WriteLine("Out of money!");
  29.                     return;
  30.                 }
  31.  
  32.  
  33.                 if (input == "Game Time")
  34.                 {
  35.                     Console.WriteLine($"Total spent: ${spentMoney:F2}. Remaining: ${currentBalance:F2}");
  36.                     break;
  37.                 }
  38.  
  39.                 if (!games.Contains(input))
  40.                 {
  41.                     Console.WriteLine("Not Found");
  42.                     continue;
  43.                 }
  44.  
  45.  
  46.                 if (input == games[0])
  47.                 {
  48.                     if (currentBalance - 39.99 < 0)
  49.                     {
  50.                         Console.WriteLine("Too Expensive");
  51.                         continue;
  52.                     }
  53.                     currentBalance -= 39.99;
  54.                     spentMoney += 39.99;
  55.                     Console.WriteLine("Bought OutFall 4");
  56.                 }
  57.                 else if (input == games[1])
  58.                 {
  59.                     if (currentBalance - 15.99 < 0)
  60.                     {
  61.                         Console.WriteLine("Too Expensive");
  62.                         continue;
  63.                     }
  64.                     currentBalance -= 15.99;
  65.                     spentMoney += 15.99;
  66.                     Console.WriteLine("Bought CS: OG");
  67.                 }
  68.                 else if (input == games[2])
  69.                 {
  70.                     if (currentBalance - 19.99 < 0)
  71.                     {
  72.                         Console.WriteLine("Too Expensive");
  73.                         continue;
  74.                     }
  75.                     currentBalance -= 19.99;
  76.                     spentMoney += 19.99;
  77.                     Console.WriteLine("Bought Zplinter Zell");
  78.                 }
  79.                 else if (input == games[3])
  80.                 {
  81.                     if (currentBalance - 59.99 < 0)
  82.                     {
  83.                         Console.WriteLine("Too Expensive");
  84.                         continue;
  85.                     }
  86.                     currentBalance -= 59.99;
  87.                     spentMoney += 59.99;
  88.                     Console.WriteLine("Bought Honored 2");
  89.                 }
  90.                 else if (input == games[4])
  91.                 {
  92.                     if (currentBalance - 29.99 < 0)
  93.                     {
  94.                         Console.WriteLine("Too Expensive");
  95.                         continue;
  96.                     }
  97.                     currentBalance -= 29.99;
  98.                     spentMoney += 29.99;
  99.                     Console.WriteLine("Bought RoverWatch");
  100.                 }
  101.                 else if (input == games[5])
  102.                 {
  103.                     if (currentBalance - 39.99 < 0)
  104.                     {
  105.                         Console.WriteLine("Too Expensive");
  106.                         continue;
  107.                     }
  108.                     currentBalance -= 39.99;
  109.                     spentMoney += 39.99;
  110.                     Console.WriteLine("Bought RoverWatch Origins Edition");
  111.                 }
  112.             }
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement