Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02._Report_System
- {
- class Program
- {
- static void Main(string[] args)
- {
- int expectedSUm = int.Parse(Console.ReadLine());
- string command = null;
- int transactionsCounter = 0;
- int cash = 0;
- int transactionCash = 0;
- int card = 0;
- int transactionCard = 0;
- while ((command = Console.ReadLine()) != "End" && cash + card < expectedSUm)
- {
- int itemsPrice = int.Parse(command);
- //По условие се редуват:
- if (transactionsCounter++ % 2 == 0)//първо плащане в брой
- {
- if (itemsPrice > 100)
- {
- Console.WriteLine($"Error in transaction!");
- }
- else
- {
- transactionCash++;
- cash += itemsPrice;
- Console.WriteLine($"Product sold!");
- }
- }
- else //след това чрез кредитна карта
- {
- if (itemsPrice < 10)
- {
- Console.WriteLine($"Error in transaction!");
- }
- else
- {
- transactionCard++;
- card += itemsPrice;
- Console.WriteLine($"Product sold!");
- }
- }
- }
- if (command == "End")
- {
- Console.WriteLine($"Failed to collect required money for charity.");
- }
- else
- {
- double totalSumCash = cash * 1.0 / transactionCash;
- double totalSumCard = card * 1.0 / transactionCard;
- Console.WriteLine($"Average CS: {totalSumCash:F2}");
- Console.WriteLine($"Average CC: {totalSumCard:F2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement