DyNaMiXx7

Untitled

Oct 29th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 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 lostMoney = 0;
  10.         double fishSum = 0;
  11.         int fishCounter = 0;
  12.         double earnedMoney = 0;
  13.  
  14.         for (int i = 1; i <= quota; i++)
  15.         {
  16.             string input = Console.ReadLine();
  17.             double fishKg = double.Parse(Console.ReadLine());
  18.             fishCounter++;
  19.             for (int counter = 0; counter < input.Length; counter++)
  20.             {
  21.                 char symbol = input[counter];
  22.                 fishSum += symbol;
  23.             }
  24.  
  25.             lostMoney += fishSum / fishKg;
  26.             fishSum = 0;
  27.  
  28.             if (i % 3 == 0 || input == "Stop")
  29.             {
  30.                 if (fishCounter == quota)
  31.                 {
  32.                     Console.WriteLine("Lyubo fulfilled the quota!");
  33.                 }
  34.                 earnedMoney = fishSum / fishKg;
  35.             }
  36.         }
  37.         if (earnedMoney > lostMoney)
  38.         {
  39.             double leftMoney = earnedMoney - lostMoney;
  40.             Console.WriteLine($"Lyubo's profit from {fishCounter} fishes is {leftMoney:F2} leva.");
  41.         }
  42.         else
  43.         {
  44.             double leftMoney = lostMoney - earnedMoney;
  45.             Console.WriteLine($"Lyubo lost {leftMoney:F2} leva today.");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment