Advertisement
Guest User

Untitled

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