Advertisement
Guest User

Untitled

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