Advertisement
silvana1303

gaming store

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