Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02_MidExamTest_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] itemsWithTheirPrices = Console.ReadLine().Split('>', '|');
- double budget = double.Parse(Console.ReadLine());
- string[] words = new string[itemsWithTheirPrices.Length / 2];
- double[] fromStrToNumber = new double[itemsWithTheirPrices.Length / 2];
- double profit = 0;
- double totalProfit = 0;
- double costs = budget;
- int startJ = 0;
- int startX = 0;
- for (int i = 0; i < itemsWithTheirPrices.Length; i++)
- {
- if (i % 2 == 0)
- {
- for (int j = startJ; j < itemsWithTheirPrices.Length / 2; j++)
- {
- if (startJ < j)
- {
- startJ = j;
- break;
- }
- words[j] = itemsWithTheirPrices[i];
- }
- }
- else
- {
- for (int x = startX; x < itemsWithTheirPrices.Length / 2; x++)
- {
- if (startX < x)
- {
- startX = x;
- break;
- }
- fromStrToNumber[x] = double.Parse(itemsWithTheirPrices[i]);
- }
- }
- }
- for (int i = 0; i < words.Length; i++)
- {
- if (words[i] == "Clothes-")
- {
- if (fromStrToNumber[i] <= 50.00 && costs > fromStrToNumber[i])
- {
- costs -= fromStrToNumber[i];
- profit = fromStrToNumber[i] * 1.40;
- totalProfit += profit;
- Console.Write($"{profit:f2} ");
- }
- }
- else if (words[i] == "Shoes-")
- {
- if (fromStrToNumber[i] <= 35.00 && costs > fromStrToNumber[i])
- {
- costs -= fromStrToNumber[i];
- profit = fromStrToNumber[i] * 1.40;
- totalProfit += profit;
- Console.Write($"{profit:f2} ");
- }
- }
- else if (words[i] == "Accessories-")
- {
- if (fromStrToNumber[i] <= 20.50 && costs > fromStrToNumber[i])
- {
- costs -= fromStrToNumber[i];
- profit = fromStrToNumber[i] * 1.40;
- totalProfit += profit;
- Console.Write($"{profit:f2} ");
- }
- }
- }
- totalProfit += costs;
- Console.WriteLine();
- if (totalProfit >= 150)
- {
- totalProfit -= budget;
- Console.WriteLine($"Profit: {totalProfit:f2}");
- Console.WriteLine($"Hello, France!");
- }
- else
- {
- totalProfit -= budget;
- Console.WriteLine($"Profit: {totalProfit:f2}");
- Console.WriteLine($"Time to go.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement