Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 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 _08.Fishing
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int quota = int.Parse(Console.ReadLine());
  14.             string word = string.Empty;
  15.             double kg = 0;
  16.             int price = 0;
  17.             double totalPrice = 0;
  18.             double loss = 0;
  19.             double profit = 0;
  20.             int i = 0;
  21.             int numberOfFish = 0;
  22.  
  23.             while (word != "Stop")
  24.             {
  25.                 for (i = 1; i <= quota; i++)
  26.                 {
  27.                     word = Console.ReadLine();
  28.                     if (word == "Stop")
  29.                     {
  30.                         break;
  31.                     }
  32.                     numberOfFish++;
  33.                     price = 0;
  34.                     kg = double.Parse(Console.ReadLine());
  35.                     for (int j = 0; j < word.Length; j++)
  36.                     {
  37.                         price += word[j];
  38.                     }
  39.                     totalPrice = Math.Round(price / kg, 2);
  40.                     if (i % 3 == 0)
  41.                     {
  42.                         profit += Math.Round(totalPrice, 2);
  43.                     }
  44.                     else
  45.                     {
  46.                         loss += Math.Round(totalPrice, 2);
  47.                     }
  48.                 }
  49.                 if (i - 1 == quota)
  50.                 {
  51.                     Console.WriteLine("Lyubo fulfilled the quota!");
  52.                     break;
  53.                 }
  54.             }
  55.             if (profit >= loss)
  56.             {
  57.                 Console.WriteLine($"Lyubo's profit from {numberOfFish} fishes is {profit - loss} leva.");
  58.             }
  59.             else if (profit < loss)
  60.             {
  61.                 Console.WriteLine($"Lyubo lost {loss - profit} leva today.");
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement