Advertisement
KeepCoding

VaporStore

Jun 24th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MySolution
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.  
  11.             double moneySpent = 0;
  12.             string gameTitle = "";
  13.  
  14.             while (gameTitle != "Game Time" && budget > 0)
  15.             {
  16.                 gameTitle = Console.ReadLine();
  17.                 double price = 0;
  18.  
  19.                 switch (gameTitle)
  20.                 {
  21.                     case "OutFall 4":
  22.                     case "RoverWatch Origins Edition":
  23.                         price = 39.99;
  24.                         break;
  25.  
  26.                     case "CS: OG":
  27.                         price = 15.99;
  28.                         break;
  29.  
  30.                     case "Zplinter Zell":
  31.                         price = 19.99;
  32.                         break;
  33.  
  34.                     case "Honored 2":
  35.                         price = 59.99;
  36.                         break;
  37.  
  38.                     case "RoverWatch":
  39.                         price = 29.99;
  40.                         break;
  41.  
  42.                     case "Game Time":
  43.                         continue;
  44.                         break;
  45.  
  46.                     default:
  47.                         Console.WriteLine("Not Found");
  48.                         continue;
  49.                         break;
  50.                 }
  51.  
  52.                 if (price <= budget)
  53.                 {
  54.                     budget -= price;
  55.                     moneySpent += price;
  56.                     Console.WriteLine($"Bought {gameTitle}");
  57.                 }
  58.                 else if (price > budget)
  59.                 {
  60.                     Console.WriteLine("Too Expensive");
  61.                 }
  62.  
  63.             }
  64.  
  65.             if (budget != 0)
  66.             {
  67.                 Console.WriteLine($"Total spent: ${moneySpent:F2}. Remaining: ${budget:F2}");
  68.             }
  69.             else
  70.             {
  71.                 Console.WriteLine("Out of money!");
  72.             }
  73.  
  74.             //main ends here
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement