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