Advertisement
Guest User

Untitled

a guest
Jun 24th, 2020
90
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 payingSystem_while_more_
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int expectedSum = int.Parse(Console.ReadLine());
  14. int totalSum = 0;
  15. int cashPay = 0;
  16. int cardPay = 0;
  17. int couter = 0;
  18. int cashCouter = 0;
  19. int cardCouter = 0;
  20.  
  21. do
  22. {
  23. string command = Console.ReadLine();
  24. if (command == "End")
  25. {
  26. break;
  27. }
  28.  
  29. else
  30. {
  31. int payment = int.Parse(command);
  32. couter++;
  33. if (couter % 2 == 0)
  34. {
  35. if (payment <=10)
  36. {
  37. Console.WriteLine("Error in transaction!");
  38. }
  39.  
  40. else
  41. {
  42. Console.WriteLine("Product is sold!");
  43. cardCouter++;
  44. cardPay += payment;
  45. }
  46. }
  47.  
  48. else
  49. {
  50. if (payment >= 100)
  51. {
  52. Console.WriteLine("Error in transaction!");
  53. }
  54.  
  55. else
  56. {
  57. Console.WriteLine("Product is sold!");
  58. cashCouter++;
  59. cashPay += payment;
  60. }
  61. }
  62. totalSum = cashPay + cardPay;
  63. }
  64.  
  65. } while (totalSum < expectedSum);
  66.  
  67. if (expectedSum <= totalSum)
  68. {
  69. Console.WriteLine($"Average CS: {cashPay / cashCouter:f2}");
  70. Console.WriteLine($"Average CS: {cardPay / cardCouter:f2}");
  71. }
  72.  
  73. else
  74. {
  75. Console.WriteLine("Failed to collect required money for charity.");
  76. }
  77.  
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement