Advertisement
Guest User

Untitled

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