Advertisement
TeMePyT

Untitled

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