Advertisement
Tervel

02. Hello, France

Feb 19th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02_MidExamTest_2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string[] itemsWithTheirPrices = Console.ReadLine().Split('>', '|');
  10. double budget = double.Parse(Console.ReadLine());
  11. string[] words = new string[itemsWithTheirPrices.Length / 2];
  12. double[] fromStrToNumber = new double[itemsWithTheirPrices.Length / 2];
  13.  
  14. double profit = 0;
  15. double totalProfit = 0;
  16. double costs = budget;
  17.  
  18. int startJ = 0;
  19. int startX = 0;
  20.  
  21. for (int i = 0; i < itemsWithTheirPrices.Length; i++)
  22. {
  23.  
  24. if (i % 2 == 0)
  25. {
  26. for (int j = startJ; j < itemsWithTheirPrices.Length / 2; j++)
  27. {
  28. if (startJ < j)
  29. {
  30. startJ = j;
  31. break;
  32. }
  33. words[j] = itemsWithTheirPrices[i];
  34. }
  35. }
  36. else
  37. {
  38. for (int x = startX; x < itemsWithTheirPrices.Length / 2; x++)
  39. {
  40. if (startX < x)
  41. {
  42. startX = x;
  43. break;
  44. }
  45. fromStrToNumber[x] = double.Parse(itemsWithTheirPrices[i]);
  46. }
  47. }
  48. }
  49.  
  50. for (int i = 0; i < words.Length; i++)
  51. {
  52.  
  53. if (words[i] == "Clothes-")
  54. {
  55. if (fromStrToNumber[i] <= 50.00 && costs > fromStrToNumber[i])
  56. {
  57. costs -= fromStrToNumber[i];
  58. profit = fromStrToNumber[i] * 1.40;
  59. totalProfit += profit;
  60. Console.Write($"{profit:f2} ");
  61. }
  62. }
  63. else if (words[i] == "Shoes-")
  64. {
  65. if (fromStrToNumber[i] <= 35.00 && costs > fromStrToNumber[i])
  66. {
  67. costs -= fromStrToNumber[i];
  68. profit = fromStrToNumber[i] * 1.40;
  69. totalProfit += profit;
  70. Console.Write($"{profit:f2} ");
  71. }
  72. }
  73. else if (words[i] == "Accessories-")
  74. {
  75. if (fromStrToNumber[i] <= 20.50 && costs > fromStrToNumber[i])
  76. {
  77. costs -= fromStrToNumber[i];
  78. profit = fromStrToNumber[i] * 1.40;
  79. totalProfit += profit;
  80. Console.Write($"{profit:f2} ");
  81. }
  82. }
  83. }
  84.  
  85. totalProfit += costs;
  86. Console.WriteLine();
  87.  
  88. if (totalProfit >= 150)
  89. {
  90. totalProfit -= budget;
  91. Console.WriteLine($"Profit: {totalProfit:f2}");
  92. Console.WriteLine($"Hello, France!");
  93. }
  94. else
  95. {
  96. totalProfit -= budget;
  97. Console.WriteLine($"Profit: {totalProfit:f2}");
  98. Console.WriteLine($"Time to go.");
  99. }
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement