Advertisement
bullit3189

Izlet

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