Advertisement
Valantina

Fishing

Jun 9th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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 fishQuota = int.Parse(Console.ReadLine());
  10.             double asciSum = 0;
  11.             int fishcount = 1;
  12.             double money = 0;
  13.             string fish = Console.ReadLine();
  14.             while (fish != "Stop")
  15.             {
  16.  
  17.                 double fishWeight = double.Parse(Console.ReadLine());
  18.                 for (int i = 0; i < fish.Length; i++)
  19.                 {
  20.                     asciSum += fish[i];
  21.                 }
  22.                 asciSum /= fishWeight;
  23.                 if (fishcount % 3 == 0)
  24.                 {
  25.                     money += asciSum;
  26.                 }
  27.                 else
  28.                 {
  29.                     money -= asciSum;
  30.                 }
  31.                 asciSum = 0;
  32.                 fishcount++;
  33.                 if (fishcount == fishQuota + 1)
  34.                 {
  35.                     Console.WriteLine("Lyubo fulfilled the quota!");
  36.                     break;
  37.                 }
  38.                 fish = Console.ReadLine();
  39.             }
  40.             if (money >= 0)
  41.             {
  42.                 Console.WriteLine($"Lyubo's profit from {fishcount - 1} fishes is {money:f2} leva.");
  43.             }
  44.             else
  45.             {
  46.                 Console.WriteLine($"Lyubo lost {Math.Abs(money):f2} leva today.");
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement