Guest User

Untitled

a guest
Jun 26th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _08.Outing
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int fishesNumber = int.Parse(Console.ReadLine());
  10.             string fishName = Console.ReadLine();
  11.  
  12.  
  13.             int fishesCount = 0;
  14.             double earnMoney = 0;
  15.             double lostMoney = 0;
  16.            
  17.  
  18.             while (fishesNumber > 0 && fishName != "Stop")
  19.             {
  20.                 double fishKilograms = double.Parse(Console.ReadLine());
  21.  
  22.                 double fishPrice = 0;
  23.                 double totalFishPrice = 0;
  24.  
  25.                 for (int i = 0; i < fishName.Length; i++)
  26.                 {
  27.                     char digit = fishName[i];
  28.                     fishPrice += digit;
  29.                 }
  30.                 totalFishPrice = fishPrice / fishKilograms;
  31.                 fishesCount++;
  32.  
  33.                 if (fishesCount % 3 == 0)
  34.                 {
  35.                     earnMoney = totalFishPrice;
  36.                 }
  37.                 else
  38.                 {
  39.                     lostMoney += totalFishPrice;
  40.                 }
  41.                 if (fishesNumber == fishesCount)
  42.                 {
  43.                     Console.WriteLine("Lyubo fulfilled the quota!");
  44.                     break;
  45.                 }
  46.                 fishName = Console.ReadLine();
  47.             }
  48.            
  49.             if (earnMoney > lostMoney)
  50.             {
  51.                 earnMoney -= lostMoney;
  52.                 Console.WriteLine($"Lyubo's profit from {fishesCount} fishes is {earnMoney:f2} leva.");
  53.             }
  54.             else
  55.             {
  56.                 lostMoney -= earnMoney;
  57.                 Console.WriteLine($"Lyubo lost {lostMoney:f2} leva today.");
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment