anizko

08. Fishing

Apr 19th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Fishing
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int Kvota = int.Parse(Console.ReadLine());
  10.             string NameFish = Console.ReadLine();
  11.  
  12.             int PriceNameFish = 0;
  13.             double PriceFish = 0;
  14.             double TotalMoney = 0;
  15.             int CountFish = 0;
  16.             double KgFish = 0;
  17.  
  18.             for (int i = 1; i <= Kvota; i++)
  19.             {
  20.                 if (NameFish != "Stop")
  21.                 {
  22.                     KgFish = double.Parse(Console.ReadLine());
  23.                     CountFish++;
  24.  
  25.                     for (int j = 0; j < NameFish.Length; j++)
  26.                     {
  27.                         char Symbol = NameFish[j];
  28.                         int NumSymbol = Symbol;
  29.  
  30.                         PriceNameFish += NumSymbol;
  31.  
  32.                     }
  33.                     PriceFish = PriceNameFish / KgFish;
  34.                     PriceNameFish = 0;
  35.  
  36.                     if (i % 3 == 0)
  37.                     {
  38.                         TotalMoney += PriceFish;
  39.                     }
  40.                     else
  41.                     {
  42.                         TotalMoney -= PriceFish;
  43.                     }
  44.  
  45.                     NameFish = Console.ReadLine();
  46.  
  47.                 }
  48.  
  49.             }
  50.  
  51.  
  52.             if (CountFish == Kvota)
  53.             {
  54.                 Console.WriteLine("Lyubo fulfilled the quota!");
  55.  
  56.             }
  57.  
  58.  
  59.  
  60.            if (TotalMoney >= 0)
  61.            {
  62.                 Console.WriteLine($"Lyubo's profit from {CountFish} fishes is {TotalMoney:f2} leva.");
  63.            }
  64.            else
  65.            {
  66.                 Console.WriteLine($"Lyubo lost {Math.Abs(TotalMoney):f2} leva today. ");
  67.            }
  68.            
  69.  
  70.            
  71.  
  72.  
  73.  
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment