Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Threading;
- namespace ConsoleApp1
- {
- class Exam
- {
- static void Main(string[] args)
- {
- string[] list = Console.ReadLine().Split('|').ToArray();
- double budget = double.Parse(Console.ReadLine());
- List<double> bought = new List<double>();
- for (int i = 0; i < list.Length; i++)
- {
- string[] cutList = list[i].Split("->").ToArray();
- if (cutList[0] == "Clothes")
- {
- budget = Clothes(budget, bought, cutList);
- }
- if (cutList[0] == "Shoes")
- {
- budget = Shoes(budget, bought, cutList);
- }
- if (cutList[0] == "Accessories")
- {
- budget = Accessories(budget, bought, cutList);
- }
- }
- double profitSum, profit;
- ProfitOperations(bought, out profitSum, out profit);
- Output(budget, bought, profitSum, profit);
- }
- private static void Output(double budget, List<double> bought, double profitSum, double profit)
- {
- for (int i = 0; i < bought.Count; i++)
- {
- Console.Write($"{bought[i]:F2} ");
- }
- Console.WriteLine();
- Console.WriteLine($"Profit: {profit:F2}");
- if (profitSum + budget >= 150)
- {
- Console.WriteLine("Hello, France!");
- }
- else
- {
- Console.WriteLine("Time to go.");
- }
- }
- private static void ProfitOperations(List<double> bought, out double profitSum, out double profit)
- {
- double boughtSum = bought.Sum();
- for (int i = 0; i < bought.Count; i++)
- {
- bought[i] *= 1.40;
- }
- profitSum = bought.Sum();
- profit = profitSum - boughtSum;
- }
- private static double Accessories(double budget, List<double> bought, string[] cutList)
- {
- double price = double.Parse(cutList[1]);
- if (price <= 20.50 && price <= budget)
- {
- budget -= price;
- bought.Add(price);
- }
- return budget;
- }
- private static double Shoes(double budget, List<double> bought, string[] cutList)
- {
- double price = double.Parse(cutList[1]);
- if (price <= 35.00 && price <= budget)
- {
- budget -= price;
- bought.Add(price);
- }
- return budget;
- }
- private static double Clothes(double budget, List<double> bought, string[] cutList)
- {
- double price = double.Parse(cutList[1]);
- if (price <= 50.00 && price <= budget)
- {
- budget -= price;
- bought.Add(price);
- }
- return budget;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement