Advertisement
Guest User

Untitled

a guest
Apr 1st, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace P02_HelloFrance
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var input = Console.ReadLine().Split("|");
  12. double money = double.Parse(Console.ReadLine());
  13.  
  14. var newPrices = new List<double>();
  15. for (int i = 0; i < input.Length; i++)
  16. {
  17. var item = input[i].Split("->");
  18. string name = item[0];
  19. double price = double.Parse(item[1]);
  20. double maxPrice = 0;
  21. if (name == "Clothes")
  22. {
  23. maxPrice = 50;
  24. }
  25. else if (name == "Shoes")
  26. {
  27. maxPrice = 35;
  28. }
  29. else if (name == "Accessories")
  30. {
  31. maxPrice = 20.5;
  32. }
  33. if (money >= price && price <= maxPrice)
  34. {
  35. money -= price;
  36. newPrices.Add(price * 1.4);
  37. }
  38. }
  39. for (int i = 0; i < newPrices.Count; i++)
  40. {
  41. Console.Write($"{newPrices[i]:f2} ");
  42. }
  43. Console.WriteLine();
  44.  
  45. money += newPrices.Sum();
  46. double profit = newPrices.Sum() - newPrices.Sum() / 1.4;
  47. Console.WriteLine($"Profit: {profit:f2}");
  48. if (money >= 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