Advertisement
alexbancheva

Hello__France_MidExam_from_10.March

Apr 13th, 2020
243
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.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Hello__France_MidExam_from_10.March
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var input = Console.ReadLine().Split("|");
  12.             double budget = double.Parse(Console.ReadLine());
  13.  
  14.             var newPrices = new List<double>();
  15.  
  16.             for (int i = 0; i < input.Length; i++)
  17.             {
  18.                 var items = input[i].Split("->");
  19.                 string name = items[0];
  20.                 double price = double.Parse(items[1]);
  21.                 double maxPrice = 0;
  22.  
  23.                 if (name == "Clothes")
  24.                 {
  25.                     maxPrice = 50;
  26.                 }
  27.                 else if (name == "Shoes")
  28.                 {
  29.                     maxPrice = 35;
  30.                 }
  31.                 else if (name == "Accessories")
  32.                 {
  33.                     maxPrice = 20.5;
  34.                 }
  35.  
  36.                 if (budget >= price && price <= maxPrice)
  37.                 {
  38.                     budget -= price;
  39.                     newPrices.Add(price * 1.4);
  40.                 }
  41.             }
  42.  
  43.             for (int i = 0; i < newPrices.Count; i++)
  44.             {
  45.                 Console.Write($"{newPrices[i]:f2} ");
  46.             }
  47.  
  48.             Console.WriteLine();
  49.  
  50.             budget += newPrices.Sum();
  51.             double profit = newPrices.Sum() - newPrices.Sum() / 1.4;
  52.             Console.WriteLine($"Profit: {profit:f2}");
  53.  
  54.             if (budget >= 150)
  55.             {
  56.                 Console.WriteLine("Hello, France!");
  57.             }
  58.             else
  59.             {
  60.                 Console.WriteLine("Time to go.");
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement