Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- double money = double.Parse(Console.ReadLine());
- string games = "";
- int index = 0;
- double spend = 0;
- double sum = 0;
- double tsena = 0;
- string[] masiv_igri = { "OutFall 4", "CS: OG", "Zplinter Zell", "Honored 2", "RoverWatch", "RoverWatch Origins Edition" };
- double[] masiv_tseni = { 39.99, 15.99, 19.99, 59.99, 29.99, 39.99 };
- do
- {
- games = Console.ReadLine();
- tsena = 0;
- for (int i = 0; i < masiv_igri.Length; i++)
- {
- if (games == masiv_igri[i])
- {
- tsena = masiv_tseni[i];
- spend += tsena;
- index = i;
- break;
- }
- }
- if (games == "Game Time")
- {
- Console.WriteLine($"Total spent: ${spend:f2}. Remaining: ${sum:f2}");
- break;
- }
- if (tsena == 0)
- {
- Console.WriteLine("Not Found");
- }
- else if (tsena > money)
- {
- Console.WriteLine("Too Expensive");
- spend = spend - tsena;
- }
- else if (spend <= money)
- {
- Console.WriteLine("Bought " + masiv_igri[index]);
- }
- if (spend >= money)
- {
- Console.WriteLine("Out of money!");
- spend -= tsena;
- break;
- }
- else
- {
- sum = money - spend;
- }
- } while (games != "Game Time");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement