Advertisement
Guest User

Untitled

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