Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- const decimal clothesMaxPrice = 50;
- const decimal shoesMaxPrice = 35;
- const decimal accessoriesMaxPrice = 20.5m;
- string[] items = Console.ReadLine().Split('|');
- decimal budget = decimal.Parse(Console.ReadLine());
- List<decimal> boughtItemPrices = new List<decimal>();
- foreach (var item in items)
- {
- string[] tokens = item.Split("->", StringSplitOptions.RemoveEmptyEntries);
- string type = tokens[0];
- decimal price = decimal.Parse(tokens[1]);
- if ((type == "Clothes" && price <= clothesMaxPrice && budget - price >= 0) ||
- (type == "Shoes" && price <= shoesMaxPrice && budget - price >= 0) ||
- (type == "Accessories" && price <= accessoriesMaxPrice && budget - price >= 0))
- {
- budget -= price;
- boughtItemPrices.Add(price);
- }
- }
- decimal oldSum = boughtItemPrices.Sum();
- boughtItemPrices = boughtItemPrices.Select(e => e *= 1.4m).ToList();
- decimal newSum = boughtItemPrices.Sum();
- decimal profit = newSum - oldSum;
- Console.WriteLine(string.Join(" ", boughtItemPrices.Select(x => x.ToString("F2"))));
- Console.WriteLine($"Profit: {profit:F2}");
- Console.WriteLine(budget + newSum >= 150 ? "Hello, France!" : "Time to go.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement