Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. decimal budget = decimal.Parse(Console.ReadLine());
  15. decimal endProfit = 0;
  16. string[] types = input.Split('|').ToArray();
  17. List<decimal> reSell = new List<decimal>();
  18.  
  19. foreach (var item in types)
  20. {
  21. string[] items = item.Split(new char[] { '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  22. string type = items[0];
  23. decimal priceTag = Convert.ToDecimal(items[1]);
  24.  
  25. if (type == "Clothes" && priceTag <= 50.00M && budget >= priceTag) //budget >= priceTag
  26. {
  27. reSell.Add(priceTag * 1.4M); // removed Math.Round
  28. budget -= priceTag;
  29. endProfit += reSell[reSell.Count - 1] - priceTag;
  30. }
  31. else if (type == "Shoes" && priceTag <= 35.00M && budget >= priceTag) //budget >= priceTag
  32. {
  33. reSell.Add(priceTag * 1.4M); // removed Math.Round
  34. budget -= priceTag;
  35. endProfit += reSell[reSell.Count - 1] - priceTag;
  36. }
  37. else if (type == "Accessories" && priceTag <= 20.50M && budget >= priceTag) //budget >= priceTag
  38. {
  39. reSell.Add(priceTag * 1.4M); // removed Math.Round
  40. budget -= priceTag;
  41. endProfit += reSell[reSell.Count - 1] - priceTag;
  42. }
  43. }
  44.  
  45. for (int i = 0; i < reSell.Count; i++) // printing {value:F2}
  46. {
  47. Console.Write($"{reSell[i]:f2} ");
  48. }
  49. Console.WriteLine();
  50.  
  51. Console.WriteLine($"Profit: {endProfit:F2}"); // printing {value:F2}
  52.  
  53. if (reSell.Sum() + budget >= 150)
  54. {
  55. Console.WriteLine("Hello, France!");
  56. }
  57. else
  58. {
  59. Console.WriteLine("Time to go.");
  60. }
  61. }
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement