Advertisement
sanyakasarova

06. Easter Decoration

Dec 11th, 2021
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. int numOfCustomers = int.Parse(Console.ReadLine());
  9.  
  10. double totalMoneySpent = 0;
  11.  
  12. for (int i = 0; i < numOfCustomers; i++)
  13. {
  14. int itemsCounter = 0;
  15. double total = 0;
  16.  
  17. string item = Console.ReadLine();
  18.  
  19. while (item != "Finish")
  20. {
  21. itemsCounter++;
  22.  
  23. switch (item)
  24. {
  25. case "basket":
  26. total += 1.50;
  27. break;
  28. case "wreath":
  29. total += 3.80;
  30. break;
  31. case "chocolate bunny":
  32. total += 7;
  33. break;
  34. }
  35.  
  36.  
  37. item = Console.ReadLine();
  38. }
  39.  
  40. if (itemsCounter % 2 == 0)
  41. {
  42. total -= total * 0.20;
  43. }
  44.  
  45. totalMoneySpent += total;
  46.  
  47. Console.WriteLine($"You purchased {itemsCounter} items for {total:f2} leva.");
  48. }
  49.  
  50. double average = totalMoneySpent / numOfCustomers;
  51.  
  52. Console.WriteLine($"Average bill per client is: {average:f2} leva.");
  53.  
  54.  
  55. }
  56.  
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement