Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. namespace GiftboxCoverage
  2. {
  3. using System;
  4. class GiftboxCoverageStart
  5. {
  6. static void Main()
  7. {
  8. int days = int.Parse(Console.ReadLine());
  9. double budget = double.Parse(Console.ReadLine());
  10. int people = int.Parse(Console.ReadLine());
  11. double fuelPrice = double.Parse(Console.ReadLine());
  12. double foodExpencesPerOne = double.Parse(Console.ReadLine());
  13. double nightExpencesPerOne = double.Parse(Console.ReadLine());
  14.  
  15. double foodExpences = days * people * foodExpencesPerOne;
  16. double hotelExpences = days * people * nightExpencesPerOne;
  17.  
  18. if (people > 10)
  19. {
  20. hotelExpences *= 0.75;
  21. }
  22.  
  23. double totalExpences = foodExpences + hotelExpences;
  24.  
  25. for (int i = 1; i <= days; i++)
  26. {
  27. double kilometers = double.Parse(Console.ReadLine());
  28. totalExpences += kilometers * fuelPrice;
  29.  
  30. if (totalExpences > budget)
  31. {
  32. Console.WriteLine($"Not enough money to continue the trip. You need {totalExpences - budget:f2}$ more.");
  33. return;
  34. }
  35. if (i % 3 == 0 || i % 5 == 0)
  36. {
  37. totalExpences *= 1.4;
  38. }
  39. if (totalExpences > budget)
  40. {
  41. Console.WriteLine($"Not enough money to continue the trip. You need {totalExpences - budget:f2}$ more.");
  42. return;
  43. }
  44. if (i % 7 == 0)
  45. {
  46. totalExpences -= totalExpences / people;
  47. }
  48.  
  49. }
  50.  
  51. Console.WriteLine($"You have reached the destination. You have {budget - totalExpences:F2}$ budget left.");
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement