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 fishes = int.Parse(Console.ReadLine());
- double savedMoney = 0;
- double lostMoney = 0;
- int counterFishes = 0;
- string name = Console.ReadLine();
- while (name != "Stop")
- {
- double weight = double.Parse(Console.ReadLine());
- for (int i = 1; i <=fishes; i++)
- {
- double valueSum = 0;
- double price = 0;
- for (int j = 0; j < name.Length; j++)
- {
- char symbol = name[j];
- valueSum+= symbol;
- }
- price = valueSum / weight;
- if (i % 3 == 0)
- {
- savedMoney += price;
- }
- else
- {
- lostMoney += price;
- }
- counterFishes++;
- if (counterFishes == fishes)
- {
- break;
- }
- name = Console.ReadLine();
- if (name == "Stop")
- {
- break;
- }
- weight = double.Parse(Console.ReadLine());
- }
- if (counterFishes == fishes)
- {
- Console.WriteLine("Lyubo fulfilled the quota!");
- break;
- }
- }
- if (savedMoney >= lostMoney)
- {
- Console.WriteLine($"Lyubo's profit from {counterFishes} fishes is {savedMoney-lostMoney:f2} leva.");
- }
- else
- {
- Console.WriteLine($"Lyubo lost {lostMoney-savedMoney:f2} leva today.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement