Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Report_System
- {
- class Program
- {
- static void Main(string[] args)
- {
- int neededMoney = int.Parse(Console.ReadLine());
- int cashCounter = 0;
- int cardCounter = 0;
- int paymentCounter = 0;
- double payCash = 0;
- double payCard = 0;
- while (neededMoney > 0)
- {
- string input = Console.ReadLine();
- if (input == "End")
- {
- Console.WriteLine("Failed to collect required money for charity.");
- return;
- }
- else
- {
- int money = int.Parse(input);
- paymentCounter++;
- if (paymentCounter % 2 == 1)
- {
- if (money > 100)
- {
- Console.WriteLine("Error in transaction!");
- continue;
- }
- cashCounter++;
- payCash += money;
- neededMoney -= money;
- Console.WriteLine("Product sold!");
- continue;
- }
- else
- {
- if (money < 10)
- {
- Console.WriteLine("Error in transaction!");
- continue;
- }
- cardCounter++;
- payCard += money;
- neededMoney -= money;
- Console.WriteLine("Product sold!");
- continue;
- }
- }
- }
- double averageCash = payCash / cashCounter;
- double averageCard = payCard / cardCounter;
- Console.WriteLine($"Average CS: {averageCash:F2}");
- Console.WriteLine($"Average CC: {averageCard:F2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement