Advertisement
Guest User

game strore

a guest
May 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Gaming_Store
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             decimal currentballance = decimal.Parse(Console.ReadLine());
  10.             decimal startBallance = currentballance;
  11.  
  12.             while (true)
  13.             {
  14.                 string game = Console.ReadLine();
  15.                 bool notFound = false;
  16.                 decimal lastBallance = currentballance;
  17.  
  18.                 switch (game)
  19.                 {
  20.                     case "Game Time":
  21.                         Console.WriteLine($"Total spent: ${startBallance - currentballance:f2}. Remaining: ${currentballance:f2}");
  22.                         notFound = true;
  23.                         return;
  24.                        
  25.                     case "OutFall 4":
  26.                         currentballance -= 39.99m;
  27.                         break;
  28.                     case "CS: OG":
  29.                         currentballance -= 15.99m;
  30.                         break;
  31.                     case "Zplinter Zell":
  32.                         currentballance -= 19.99m;
  33.                         break;
  34.                     case "Honored 2":
  35.                         currentballance -= 59.99m;
  36.                         break;
  37.                     case "RoverWatch":
  38.                         currentballance -= 29.99m;
  39.                         break;
  40.                     case "RoverWatch Origins Edition":
  41.                         currentballance -= 39.99m;
  42.                         break;
  43.                     default:
  44.                         Console.WriteLine("Not Found");
  45.                         notFound = true;
  46.                         continue;
  47.                 }
  48.                 if (currentballance >= 0 && notFound == false)
  49.                 {
  50.                     Console.WriteLine($"Bought {game}");
  51.                     if (currentballance == 0)
  52.                     {
  53.                         Console.WriteLine("Out of money!");
  54.                         return;
  55.                     }
  56.                 }
  57.                 else if (currentballance < 0)
  58.                 {
  59.                     Console.WriteLine("Too Expensive");
  60.                     currentballance = lastBallance;
  61.                 }
  62.  
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement