Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. int clients = int.Parse(Console.ReadLine());
  2. string item = string.Empty;
  3. double purchasePrice = 0;
  4. int purchasedItems = 0;
  5. double totalPurchased = 0;
  6. double price = 0;
  7. int purchasedByClient = 0;
  8.  
  9. for (int i = 1; i <= clients; i++)
  10. {
  11. purchasePrice = 0;
  12. purchasedByClient = 0;
  13.  
  14. while ((item = Console.ReadLine()) != "Finish")
  15. {
  16. switch (item)
  17. {
  18. case "basket":
  19. price = 1.50;
  20. purchasePrice += price;
  21.  
  22. purchasedItems++;
  23. purchasedByClient++;
  24. break;
  25. case "wreath":
  26. price = 3.80;
  27. purchasePrice += price;
  28.  
  29. purchasedItems++;
  30. purchasedByClient++;
  31. break;
  32. case "chocolate bunny":
  33. price = 7.00;
  34. purchasePrice += price;
  35.  
  36. purchasedItems++;
  37. purchasedByClient++;
  38. break;
  39. }
  40.  
  41. }
  42. if (purchasedByClient % 2 == 0)
  43. {
  44. purchasePrice *= 0.80;
  45. }
  46. totalPurchased += purchasePrice;
  47. if (item == "Finish")
  48. {
  49. Console.WriteLine($"You purchased {purchasedByClient} items for {purchasePrice:f2} leva.");
  50. }
  51.  
  52. }
  53.  
  54. Console.WriteLine($"Average bill per client is: {(totalPurchased/(double)clients):f2} leva.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement