knikolov98

Untitled

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