Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _08._Fishing
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int quota = int.Parse(Console.ReadLine());
  10. string fishName = Console.ReadLine();
  11. int fishCount = 0;
  12. double profit = 0.0;
  13. while (fishName != "Stop")
  14. {
  15. double fishKg = double.Parse(Console.ReadLine());
  16. fishCount++;
  17.  
  18. double price = 0;
  19. for (int i = 0; i < fishName.Length; i++)
  20. {
  21. price += fishName[i];
  22. }
  23. if(fishCount % 3 == 0)
  24. {
  25. profit += price / fishKg ;
  26. }
  27. else
  28. {
  29. profit -= price / fishKg;
  30. }
  31. if (fishCount == quota)
  32. {
  33. Console.WriteLine("Lyubo fulfilled the quota!");
  34. break;
  35. }
  36. fishName = Console.ReadLine();
  37. }
  38. if (profit >= 0)
  39. {
  40. Console.WriteLine($"Lyubo's profit from {fishCount} fishes is {profit:f2} leva.");
  41. }
  42. else
  43. {
  44. Console.WriteLine($"Lyubo lost {Math.Abs(profit):f2} leva today.");
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement