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