Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Hello_France
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string[] itemsList = Console.ReadLine().Split('|').ToArray();
  12. double budget = double.Parse(Console.ReadLine());
  13. double sumLeft = budget;
  14. List<double> pricesOfBoughtItems = new List<double>();
  15. double moneyEarned = 0;
  16. for (int i = 0; i < itemsList.Length; i++)
  17. {
  18. string[] itemAndPrice = itemsList[i].Split("->").ToArray();
  19. string item = itemAndPrice[0];
  20. double price = double.Parse(itemAndPrice[1]);
  21. switch(item)
  22. {
  23. case "Clothes":
  24. if (price<=50.00&&(sumLeft-price)>=0)
  25. {
  26. sumLeft -= price;
  27. pricesOfBoughtItems.Add(price);
  28. }
  29. break;
  30. case "Shoes":
  31. if (price <= 35.00 && (sumLeft - price) >= 0)
  32. {
  33. sumLeft -= price;
  34. pricesOfBoughtItems.Add(price);
  35. }
  36. break;
  37. case "Accessories":
  38. if (price <= 20.50 && (sumLeft - price) >= 0)
  39. {
  40. sumLeft -= price;
  41. pricesOfBoughtItems.Add(price);
  42. }
  43. break;
  44. }
  45.  
  46. }
  47. if(pricesOfBoughtItems.Count>0)
  48. {
  49. for (int i = 0; i < pricesOfBoughtItems.Count; i++)
  50. {
  51. pricesOfBoughtItems[i] = Math.Round((pricesOfBoughtItems[i] * 1.40), 2);
  52. moneyEarned += pricesOfBoughtItems[i];
  53. }
  54. }
  55.  
  56. double profit = Math.Round(((moneyEarned + sumLeft)-budget),2);
  57. foreach (var price in pricesOfBoughtItems)
  58. {
  59. Console.Write($"{price:f2} ");
  60. }
  61. Console.WriteLine();
  62. Console.WriteLine($"Profit: {profit:f2}");
  63. if((moneyEarned+sumLeft)>=150)
  64. {
  65. Console.WriteLine("Hello, France!");
  66. }
  67. else
  68. {
  69. Console.WriteLine("Time to go.");
  70. }
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement