Advertisement
ElviraPetkova

Gaming Store

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