Advertisement
spasnikolov131

Untitled

Oct 13th, 2023
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Report_System
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int sum = int.Parse(Console.ReadLine());
  10.  
  11. double totalMoney = 0;
  12. double card = 0;
  13. double cash = 0;
  14. int count = 0;
  15.  
  16. while (totalMoney <= sum)
  17. {
  18. string itemsPrice = Console.ReadLine();
  19.  
  20. if (itemsPrice == "End")
  21. {
  22. Console.WriteLine("Failed to collect required money for charity.");
  23. break;
  24. }
  25.  
  26.  
  27.  
  28.  
  29. count++;
  30. if (count % 2 != 0)
  31. {
  32. // плащане в брой
  33. if (Math.Abs(int.Parse(itemsPrice)) > 100)
  34. {
  35.  
  36. Console.WriteLine("Error in transaction!");
  37.  
  38. // отхърлено
  39. }
  40. else
  41. {
  42. cash += int.Parse(itemsPrice);
  43. Console.WriteLine("Product sold!");
  44. }
  45. }
  46.  
  47. else
  48. {
  49. // плащане с карта
  50. if (Math.Abs(int.Parse(itemsPrice)) < 10)
  51. {
  52.  
  53. Console.WriteLine("Error in transaction!");
  54.  
  55. // отхвърлено
  56. }
  57. else
  58. {
  59. card += int.Parse(itemsPrice);
  60. Console.WriteLine("Product sold!");
  61. }
  62. }
  63. totalMoney = card + cash;
  64.  
  65. }
  66. if (totalMoney >= sum)
  67. {
  68. Console.WriteLine($"Average CS: {cash / 2:f2}");
  69. Console.WriteLine($"Average CC: {card / 2:f2}");
  70. }
  71.  
  72. }
  73. }
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement