Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02._Hello__France
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var list = Console.ReadLine()
  12.                 .Split("|")
  13.                 .ToList();
  14.             double budget = double.Parse(Console.ReadLine());
  15.             double profit = 0;
  16.             var items = new List<double>();
  17.  
  18.             for (int i = 0; i < list.Count; i++)
  19.             {
  20.                 string type = list[i].Split("->")[0];
  21.                 double price = double.Parse(list[i].Split("->")[1]);
  22.                 if (type == "Clothes" && price <= 50.00 && budget - price >= 0)
  23.                 {
  24.                     budget -= price;
  25.                     items.Add(price * 1.4);
  26.                 }
  27.                 if (type == "Shoes" && price <= 35.00 && budget - price >= 0)
  28.                 {
  29.                     budget -= price;
  30.                     items.Add(price * 1.4);
  31.                 }
  32.                 if (type == "Accessories" && price <= 20.50 && budget - price >= 0)
  33.                 {
  34.                     budget -= price;
  35.                     items.Add(price * 1.4);          }
  36.             }
  37.  
  38.             foreach (var number in items)
  39.             {
  40.                 Console.Write($"{number:f2} ");
  41.             }
  42.             Console.WriteLine();
  43.  
  44.             profit = items.Sum() - items.Sum() / 1.4;
  45.  
  46.             Console.WriteLine($"Profit: {profit:F2}");
  47.          
  48.             if (budget + items.Sum(x => x) >= 150)
  49.             {
  50.                 Console.WriteLine("Hello, France!");
  51.             }
  52.             else
  53.             {
  54.                 Console.WriteLine("Time to go.");
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement