Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace payingSystem_while_more_
- {
- class Program
- {
- static void Main(string[] args)
- {
- int expectedSum = int.Parse(Console.ReadLine());
- int totalSum = 0;
- int cashPay = 0;
- int cardPay = 0;
- int couter = 0;
- int cashCouter = 0;
- int cardCouter = 0;
- do
- {
- string command = Console.ReadLine();
- if (command == "End")
- {
- break;
- }
- else
- {
- int payment = int.Parse(command);
- couter++;
- if (couter % 2 == 0)
- {
- if (payment <=10)
- {
- Console.WriteLine("Error in transaction!");
- }
- else
- {
- Console.WriteLine("Product is sold!");
- cardCouter++;
- cardPay += payment;
- }
- }
- else
- {
- if (payment >= 100)
- {
- Console.WriteLine("Error in transaction!");
- }
- else
- {
- Console.WriteLine("Product is sold!");
- cashCouter++;
- cashPay += payment;
- }
- }
- totalSum = cashPay + cardPay;
- }
- } while (totalSum < expectedSum);
- if (expectedSum <= totalSum)
- {
- Console.WriteLine($"Average CS: {cashPay / cashCouter:f2}");
- Console.WriteLine($"Average CS: {cardPay / cardCouter:f2}");
- }
- else
- {
- Console.WriteLine("Failed to collect required money for charity.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement