Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ReportSystem
- {
- class Program
- {
- static void Main()
- {
- int totalSum = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- int payCash = 0;
- int payCard = 0;
- int payCashCounter = 0;
- int payCardCounter = 0;
- int paymentCounter = 0;
- while (input != "End" && totalSum > 0)
- {
- paymentCounter++;
- int productPrice = int.Parse(input);
- if (paymentCounter % 2 != 0 && productPrice <= 100 )
- {
- payCashCounter++;
- totalSum -= productPrice;
- payCash += productPrice;
- Console.WriteLine($"Product sold!");
- }
- else if(paymentCounter % 2 != 0 && productPrice > 100 )
- {
- Console.WriteLine("Error in transaction!");
- }
- if(paymentCounter % 2 == 0 && productPrice >= 10 )
- {
- payCardCounter++;
- totalSum -= productPrice;
- payCard += productPrice;
- Console.WriteLine("Product sold!");
- }
- else if(payCardCounter % 2 == 0 && productPrice < 10)
- {
- Console.WriteLine("Error in transaction!");
- }
- input = Console.ReadLine();
- }
- if (totalSum <= 0)
- {
- Console.WriteLine($"Average CS: {1.0 * payCash / payCardCounter:f2}");
- Console.WriteLine($"Average CC: {1.0 * payCard / payCardCounter:f2}");
- }
- else
- {
- Console.WriteLine("Failed to collect required money for charity.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment