Advertisement
Guest User

Fishing

a guest
Jun 5th, 2019
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 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 dailyCatch = int.Parse(Console.ReadLine());
  10.             string fishName = string.Empty;
  11.             double fishKg = 0;
  12.             int fishCounter = 0;
  13.             double fishPriceSum = 0;
  14.             double fishPrice = 0;
  15.             double lostMoney = 0;
  16.             double winMoney = 0;
  17.             for (int i = 1; i <= dailyCatch; i++)
  18.             {
  19.                 fishName = Console.ReadLine();
  20.                 if (fishName=="Stop")
  21.                 {
  22.                     break;
  23.                 }
  24.                 fishKg = double.Parse(Console.ReadLine());
  25.                 for (int j = 0; j <fishName.Length; j++)
  26.                 {
  27.                    
  28.                     fishPriceSum += fishName[j];
  29.                    
  30.                 }                
  31.                 fishPrice = fishPriceSum / fishKg;
  32.                 fishPriceSum = 0;
  33.                 if (i % 3 == 0 &&i!=0)
  34.                 {
  35.  
  36.                     winMoney += fishPrice;
  37.                 }
  38.                 else
  39.                 {
  40.  
  41.                     lostMoney += fishPrice;
  42.                 }
  43.                 fishCounter++;
  44.                
  45.             }
  46.             if (dailyCatch==fishCounter)
  47.             {
  48.                 Console.WriteLine("Lyubo fulfilled the quota!");
  49.             }
  50.             if (winMoney>lostMoney)
  51.             {
  52.                 double winSum = winMoney - lostMoney;
  53.                 Console.WriteLine($"Lyubo's profit from {fishCounter} fishes is {winSum:f2} leva.");
  54.             }
  55.             else
  56.             {
  57.                 Console.WriteLine($"Lyubo lost {lostMoney:f2} leva today.");
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement