Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2019
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08.Fishing
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int quota = int.Parse(Console.ReadLine());
  14. string word = string.Empty;
  15. double kg = 0;
  16. int price = 0;
  17. double totalPrice = 0;
  18. double loss = 0;
  19. double profit = 0;
  20. int i = 0;
  21. int numberOfFish = 0;
  22.  
  23. while (word != "Stop")
  24. {
  25. for (i = 1; i <= quota; i++)
  26. {
  27. word = Console.ReadLine();
  28. if (word == "Stop")
  29. {
  30. break;
  31. }
  32. numberOfFish++;
  33. price = 0;
  34. kg = double.Parse(Console.ReadLine());
  35. for (int j = 0; j < word.Length; j++)
  36. {
  37. price += word[j];
  38. }
  39. totalPrice = price / kg;
  40. if (i % 3 == 0)
  41. {
  42. profit += totalPrice;
  43. }
  44. else
  45. {
  46. loss += totalPrice;
  47. }
  48. }
  49. if (i - 1 == quota)
  50. {
  51. Console.WriteLine("Lyubo fulfilled the quota!");
  52. break;
  53. }
  54. }
  55.  
  56. if (profit > loss)
  57. {
  58. profit = Math.Round(profit-loss,2);
  59. Console.WriteLine($"Lyubo's profit from {numberOfFish} fishes is {profit} leva.");
  60. }
  61. else if (profit <= loss)
  62. {
  63. loss = Math.Round(loss-profit,2);
  64. Console.WriteLine($"Lyubo lost {loss} leva today.");
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement