Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace P03_Gaming_Store
- {
- class Program
- {
- static void Main(string[] args)
- {
- double balance = double.Parse(Console.ReadLine());
- double spend = 0;
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "Game Time")
- {
- break;
- }
- double price = 0;
- switch (command)
- {
- case "OutFall 4": price = 39.99; break;
- case "CS: OG": price = 15.99; break;
- case "Zplinter Zell": price = 19.99; break;
- case "Honored 2": price = 59.99; break;
- case "RoverWatch": price = 29.99; break;
- case "RoverWatch Origins Edition": price = 39.99; break;
- default: Console.WriteLine("Not Found"); continue;
- }
- if(balance < price)
- {
- Console.WriteLine("Too Expensive");
- continue;
- }
- balance -= price;
- spend += price;
- Console.WriteLine($"Bought {command}");
- if (balance == 0)
- {
- Console.WriteLine("Out of money!");
- return;
- }
- }
- Console.WriteLine($"Total spent: ${spend:f2}. Remaining: ${balance:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement