Advertisement
Guest User

08 FISHING

a guest
Mar 27th, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Lubo_fisherman
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             string fish = string.Empty;
  15.             double profit = 0;
  16.             double price = 0.00;
  17.             int count = 0;
  18.  
  19.  
  20.             while (fish != "Stop")
  21.             {
  22.                 for (int i = 1; i <= n; i++)
  23.                 {
  24.                     fish = Console.ReadLine();
  25.                     if (fish == "Stop")
  26.                     { break; }
  27.                     double kg = double.Parse(Console.ReadLine());
  28.                     for (int m = 0; m < fish.Length; m++)
  29.                     {
  30.                         price += fish[m];
  31.                        
  32.                     }
  33.                     price = (price / kg);
  34.                     if (i == 3)
  35.                     {
  36.                         profit += price;
  37.                     }
  38.                     else
  39.                     {
  40.                         profit -= price;
  41.                     }
  42.                     count++;
  43.                     price = 0;
  44.                  
  45.                 }
  46.                
  47.                 if (count == n)
  48.                 {
  49.                     Console.WriteLine("Lyubo fulfilled the quota!");
  50.                     break;
  51.                 }
  52.             }
  53.             if (profit >= 0)
  54.             {
  55.                 Console.WriteLine($"Lyubo's profit from {count} fishes is {profit:f2} leva.");
  56.             }
  57.             else
  58.             {
  59.                 Console.WriteLine($"Lyubo lost {Math.Abs(profit):f2} leva today.");
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement