Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _08.Fishing
- {
- class Program
- {
- static void Main(string[] args)
- {
- int quota = int.Parse(Console.ReadLine());
- string word = string.Empty;
- double kg = 0;
- int price = 0;
- double totalPrice = 0;
- double loss = 0;
- double profit = 0;
- int i = 0;
- int numberOfFish = 0;
- while (word != "Stop")
- {
- for (i = 1; i <= quota; i++)
- {
- word = Console.ReadLine();
- if (word == "Stop")
- {
- break;
- }
- numberOfFish++;
- price = 0;
- kg = double.Parse(Console.ReadLine());
- for (int j = 0; j < word.Length; j++)
- {
- price += word[j];
- }
- totalPrice = Math.Round(price / kg, 2);
- if (i % 3 == 0)
- {
- profit += Math.Round(totalPrice, 2);
- }
- else
- {
- loss += Math.Round(totalPrice, 2);
- }
- }
- if (i - 1 == quota)
- {
- Console.WriteLine("Lyubo fulfilled the quota!");
- break;
- }
- }
- if (profit >= loss)
- {
- Console.WriteLine($"Lyubo's profit from {numberOfFish} fishes is {profit - loss} leva.");
- }
- else if (profit < loss)
- {
- Console.WriteLine($"Lyubo lost {loss - profit} leva today.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement