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());
- decimal profit = 0;
- for (int i = 1; i <= quota; i++)
- {
- string fishName = Console.ReadLine();
- if (fishName=="Stop")
- {
- if (profit >= 0)
- {
- Console.WriteLine($"Lyubo's profit from {i-1} fishes is {profit:f2} leva.");
- }
- else
- {
- Console.WriteLine($"Lyubo lost {Math.Abs(profit):f2} leva today.");
- }
- return;
- }
- decimal fishWeight = decimal.Parse(Console.ReadLine());
- decimal price = 0;
- int asciSum = 0;
- for (int j = 0; j < fishName.Length; j++)
- {
- char asciChar = char.Parse(fishName[j].ToString());
- int asci = asciChar;
- asciSum += asci;
- }
- price = asciSum / fishWeight;
- if (i % 3 == 0)
- {
- profit += price;
- }
- else
- {
- profit -= price;
- }
- }
- Console.WriteLine("Lyubo fulfilled the quota!");
- if (profit >= 0)
- {
- Console.WriteLine($"Lyubo's profit from {quota} fishes is {profit:f2} leva.");
- }
- else
- {
- Console.WriteLine($"Lyubo lost {profit:f2} leva today.");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement