Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - More Exercise (03. Gaming Store)

Jun 18th, 2021
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace GamingStore
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal money = decimal.Parse(Console.ReadLine());
  14.             string game = Console.ReadLine();
  15.             decimal totalSpend = 0;
  16.  
  17.             while (game != "Game Time")
  18.             {
  19.                
  20.                 if (game == "OutFall 4")
  21.                 {
  22.                     if (money >= 39.99m)
  23.                     {
  24.                         money -= 39.99m;
  25.                         totalSpend += 39.99m;
  26.                         Console.WriteLine($"Bought {game}");
  27.                     }
  28.                     else
  29.                     {
  30.                         Console.WriteLine("Too Expensive");
  31.                     }
  32.                 }
  33.                 else if (game == "CS: OG")
  34.                 {
  35.                     if (money >= 15.99m)
  36.                     {
  37.                         money -= 15.99m;
  38.                         totalSpend += 15.99m;
  39.                         Console.WriteLine($"Bought {game}");
  40.                     }
  41.                     else
  42.                     {
  43.                         Console.WriteLine("Too Expensive");
  44.                     }
  45.                 }
  46.                 else if (game == "Zplinter Zell")
  47.                 {
  48.                     if (money >= 19.99m)
  49.                     {
  50.                         money -= 19.99m;
  51.                         totalSpend += 19.99m;
  52.                         Console.WriteLine($"Bought {game}");
  53.                     }
  54.                     else
  55.                     {
  56.                         Console.WriteLine("Too Expensive");
  57.                     }
  58.                 }
  59.                 else if (game == "Honored 2")
  60.                 {
  61.                     if (money >= 59.99m)
  62.                     {
  63.                         money -= 59.99m;
  64.                         totalSpend += 59.99m;
  65.                         Console.WriteLine($"Bought {game}");
  66.                     }
  67.                     else
  68.                     {
  69.                         Console.WriteLine("Too Expensive");
  70.                     }
  71.                 }
  72.                 else if (game == "RoverWatch")
  73.                 {
  74.                     if (money >= 29.99m)
  75.                     {
  76.                         money -= 29.99m;
  77.                         totalSpend += 29.99m;
  78.                         Console.WriteLine($"Bought {game}");
  79.                     }
  80.                     else
  81.                     {
  82.                         Console.WriteLine("Too Expensive");
  83.                     }
  84.                 }
  85.                 else if (game == "RoverWatch Origins Edition")
  86.                 {
  87.                     if (money >= 39.99m)
  88.                     {
  89.                         money -= 39.99m;
  90.                         totalSpend += 39.99m;
  91.                         Console.WriteLine($"Bought {game}");
  92.                     }
  93.                     else
  94.                     {
  95.                         Console.WriteLine("Too Expensive");
  96.                     }
  97.                 }
  98.                 else
  99.                 {
  100.                     Console.WriteLine("Not Found");
  101.                 }
  102.  
  103.  
  104.                 if (money == 0)
  105.                 {
  106.                     Console.WriteLine("Out of money!");
  107.                     Environment.Exit(0);
  108.                 }
  109.  
  110.                 game = Console.ReadLine();
  111.  
  112.             }
  113.             Console.WriteLine($"Total spent: ${totalSpend:F2}. Remaining: ${money:F2}");
  114.         }
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement