Advertisement
Guest User

Untitled

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