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