DyNaMiXx7

Untitled

Oct 29th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int quota = int.Parse(Console.ReadLine());
  8.  
  9.         double profit = 0;
  10.         double expenses = 0;
  11.         int fishCounter = 0;
  12.  
  13.         for (int i = 1; i <= quota; i++)
  14.         {
  15.             string input = Console.ReadLine();
  16.             if (input == "Stop")
  17.             {
  18.                 break;
  19.             }
  20.             double fishKg = double.Parse(Console.ReadLine());
  21.             if (i % 3 == 0)
  22.             {
  23.                 double currentProfit = 0;
  24.                 for (int counter = 0; counter < input.Length; counter++)
  25.                 {
  26.                     char symbol = input[counter];
  27.                     currentProfit += symbol;
  28.                 }
  29.                 profit += currentProfit / fishKg;
  30.             }
  31.             else
  32.             {
  33.                 double currentExpenses = 0;
  34.                 for (int counter = 0; counter < input.Length; counter++)
  35.                 {
  36.                     char symbol = input[counter];
  37.                     currentExpenses += symbol;
  38.                 }
  39.                 expenses += currentExpenses / fishKg;
  40.             }
  41.  
  42.             if (i == quota)
  43.             {
  44.                 Console.WriteLine("Lyubo fulfilled the quota!");
  45.             }
  46.             fishCounter++;
  47.         }
  48.         if (profit > expenses)
  49.         {
  50.             double leftMoney = profit - expenses;
  51.             Console.WriteLine($"Lyubo's profit from {fishCounter} fishes is {leftMoney:F2} leva.");
  52.         }
  53.         else
  54.         {
  55.             double leftMoney = expenses - profit;
  56.             Console.WriteLine($"Lyubo lost {leftMoney:F2} leva today.");
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment