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