Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Hello_France
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] itemsList = Console.ReadLine().Split('|').ToArray();
- double budget = double.Parse(Console.ReadLine());
- double sumLeft = budget;
- List<double> pricesOfBoughtItems = new List<double>();
- double moneyEarned = 0;
- for (int i = 0; i < itemsList.Length; i++)
- {
- string[] itemAndPrice = itemsList[i].Split("->").ToArray();
- string item = itemAndPrice[0];
- double price = double.Parse(itemAndPrice[1]);
- switch(item)
- {
- case "Clothes":
- if (price<=50.00&&(sumLeft-price)>=0)
- {
- sumLeft -= price;
- pricesOfBoughtItems.Add(price);
- }
- break;
- case "Shoes":
- if (price <= 35.00 && (sumLeft - price) >= 0)
- {
- sumLeft -= price;
- pricesOfBoughtItems.Add(price);
- }
- break;
- case "Accessories":
- if (price <= 20.50 && (sumLeft - price) >= 0)
- {
- sumLeft -= price;
- pricesOfBoughtItems.Add(price);
- }
- break;
- }
- }
- if(pricesOfBoughtItems.Count>0)
- {
- for (int i = 0; i < pricesOfBoughtItems.Count; i++)
- {
- pricesOfBoughtItems[i] = Math.Round((pricesOfBoughtItems[i] * 1.40), 2);
- moneyEarned += pricesOfBoughtItems[i];
- }
- }
- double profit = Math.Round(((moneyEarned + sumLeft)-budget),2);
- foreach (var price in pricesOfBoughtItems)
- {
- Console.Write($"{price:f2} ");
- }
- Console.WriteLine();
- Console.WriteLine($"Profit: {profit:f2}");
- if((moneyEarned+sumLeft)>=150)
- {
- Console.WriteLine("Hello, France!");
- }
- else
- {
- Console.WriteLine("Time to go.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement