VickSuna

Untitled

Mar 9th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02._Report_System
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int goal = int.Parse(Console.ReadLine());
  10.  
  11. int counter = 1;
  12.  
  13. int addedSum = 0;
  14.  
  15. string command = Console.ReadLine();
  16.  
  17. int cash = 0;
  18. int cashTrans = 0;
  19.  
  20. int card = 0;
  21. int cardTrans = 0;
  22.  
  23. while (command != "End")
  24. {
  25. int currentSum = int.Parse(command);
  26.  
  27. if (counter % 2 != 0 && currentSum <= 100)
  28. {
  29. addedSum += currentSum;
  30. cash += currentSum;
  31. cashTrans++;
  32. Console.WriteLine("Product sold!");
  33. }
  34. if (counter % 2 != 0 && currentSum > 100)
  35. {
  36. Console.WriteLine("Error in transaction!");
  37. }
  38. if (counter % 2 == 0 && currentSum >= 10)
  39. {
  40. addedSum += currentSum;
  41. card += currentSum;
  42. cardTrans++;
  43. Console.WriteLine("Product sold!");
  44. }
  45. if (counter % 2 == 0 && currentSum < 10)
  46. {
  47. Console.WriteLine("Error in transaction!");
  48. }
  49.  
  50. counter++;
  51.  
  52. double averCash = cash * 1.0 / cashTrans;
  53. double averCard = card * 1.0 / cardTrans;
  54.  
  55.  
  56. if (addedSum >= goal)
  57. {
  58. Console.WriteLine($"Average CS: {averCash:F2}");
  59. Console.WriteLine($"Average CC: {averCard:F2}");
  60. break;
  61. }
  62.  
  63. command = Console.ReadLine();
  64.  
  65. }
  66.  
  67. if (command == "End")
  68. {
  69. Console.WriteLine("Failed to collect required money for charity.");
  70. }
  71.  
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment