Advertisement
MARINA_GREBENAROVA

Report_System

Oct 15th, 2021
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Report_System
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int neededMoney = int.Parse(Console.ReadLine());
  10.  
  11.             int cashCounter = 0;
  12.             int cardCounter = 0;
  13.             int paymentCounter = 0;
  14.  
  15.             double payCash = 0;
  16.             double payCard = 0;
  17.  
  18.             while (neededMoney > 0)
  19.             {
  20.                 string input = Console.ReadLine();
  21.                 if (input == "End")
  22.                 {
  23.                     Console.WriteLine("Failed to collect required money for charity.");
  24.                     return;
  25.                 }
  26.                 else
  27.                 {
  28.                     int money = int.Parse(input);
  29.                     paymentCounter++;
  30.                     if (paymentCounter % 2 == 1)
  31.                     {
  32.                         if (money > 100)
  33.                         {
  34.                             Console.WriteLine("Error in transaction!");
  35.                             continue;
  36.                         }
  37.                         cashCounter++;
  38.                         payCash += money;
  39.                         neededMoney -= money;
  40.                         Console.WriteLine("Product sold!");
  41.                         continue;
  42.  
  43.                     }
  44.                     else
  45.                     {
  46.                         if (money < 10)
  47.                         {
  48.                             Console.WriteLine("Error in transaction!");
  49.                             continue;
  50.                         }
  51.                         cardCounter++;
  52.                         payCard += money;
  53.                         neededMoney -= money;
  54.                         Console.WriteLine("Product sold!");
  55.                         continue;
  56.                     }
  57.                 }
  58.  
  59.             }
  60.             double averageCash = payCash / cashCounter;
  61.             double averageCard = payCard / cardCounter;
  62.  
  63.             Console.WriteLine($"Average CS: {averageCash:F2}");
  64.             Console.WriteLine($"Average CC: {averageCard:F2}");
  65.  
  66.         }
  67.     }
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement