Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
597
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.  
  40. for (int i = 0; i < newPrices.Count; i++)
  41. {
  42. Console.Write($"{newPrices[i]:f2} ");
  43. }
  44. Console.WriteLine();
  45.  
  46. money += newPrices.Sum();
  47. double profit = newPrices.Sum() - newPrices.Sum() / 1.4;
  48. Console.WriteLine($"Profit: {profit:f2}");
  49.  
  50. if (money >= 150)
  51. {
  52. Console.WriteLine("Hello, France!");
  53. }
  54. else
  55. {
  56. Console.WriteLine("Time to go.");
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement