Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _08._Fishing
- {
- class Program
- {
- static void Main(string[] args)
- {
- int quota = int.Parse(Console.ReadLine());
- string fishName = Console.ReadLine();
- int fishCount = 0;
- double profit = 0.0;
- while (fishName != "Stop")
- {
- double fishKg = double.Parse(Console.ReadLine());
- fishCount++;
- double price = 0;
- for (int i = 0; i < fishName.Length; i++)
- {
- price += fishName[i];
- }
- if(fishCount % 3 == 0)
- {
- profit += price / fishKg ;
- }
- else
- {
- profit -= price / fishKg;
- }
- if (fishCount == quota)
- {
- Console.WriteLine("Lyubo fulfilled the quota!");
- break;
- }
- fishName = Console.ReadLine();
- }
- if (profit >= 0)
- {
- Console.WriteLine($"Lyubo's profit from {fishCount} fishes is {profit:f2} leva.");
- }
- else
- {
- Console.WriteLine($"Lyubo lost {Math.Abs(profit):f2} leva today.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement