Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Report_System
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int sum = int.Parse(Console.ReadLine());
- double totalMoney = 0;
- double card = 0;
- double cash = 0;
- int count = 0;
- while (totalMoney <= sum)
- {
- string itemsPrice = Console.ReadLine();
- if (itemsPrice == "End")
- {
- Console.WriteLine("Failed to collect required money for charity.");
- break;
- }
- count++;
- if (count % 2 != 0)
- {
- // плащане в брой
- if (Math.Abs(int.Parse(itemsPrice)) > 100)
- {
- Console.WriteLine("Error in transaction!");
- // отхърлено
- }
- else
- {
- cash += int.Parse(itemsPrice);
- Console.WriteLine("Product sold!");
- }
- }
- else
- {
- // плащане с карта
- if (Math.Abs(int.Parse(itemsPrice)) < 10)
- {
- Console.WriteLine("Error in transaction!");
- // отхвърлено
- }
- else
- {
- card += int.Parse(itemsPrice);
- Console.WriteLine("Product sold!");
- }
- }
- totalMoney = card + cash;
- }
- if (totalMoney >= sum)
- {
- Console.WriteLine($"Average CS: {cash / 2:f2}");
- Console.WriteLine($"Average CC: {card / 2:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement