Advertisement
alexbancheva

Fishing boat

Nov 14th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Fishing_Boat
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int budget = int.Parse(Console.ReadLine());
  10. string season = Console.ReadLine();
  11.  
  12. int numFisher = int.Parse(Console.ReadLine());
  13. bool flag = true;
  14.  
  15. double boatRent = 0;
  16. double totalPrice = 0;
  17.  
  18.  
  19. switch (season)
  20. {
  21. case "Spring":
  22. boatRent = 3000;
  23. break;
  24.  
  25. case "Winter":
  26. boatRent = 2600;
  27. break;
  28.  
  29. case "Summer":
  30. boatRent = 4200;
  31. break;
  32.  
  33. case "Autumn":
  34. boatRent = 4200;
  35. break;
  36.  
  37. default: flag = false;
  38. break;
  39. }
  40.  
  41.  
  42. if (flag)
  43. {
  44.  
  45. if (numFisher <= 6)
  46. {
  47. totalPrice = boatRent - 0.1 * boatRent;
  48. }
  49. else if (numFisher >= 7 && numFisher <= 11)
  50. {
  51. totalPrice = boatRent - 0.15 * boatRent;
  52.  
  53. }
  54. else if (numFisher >= 12)
  55. {
  56. totalPrice = boatRent - 0.25 * boatRent;
  57. }
  58.  
  59. if (numFisher % 2 == 0 && season != "Autumn")
  60. {
  61. totalPrice = totalPrice - totalPrice * 0.05;
  62. }
  63.  
  64.  
  65. if (budget >= totalPrice)
  66. {
  67. Console.WriteLine($"Yes! You have {budget-totalPrice:f2} leva left.");
  68.  
  69. }
  70. else
  71. {
  72. Console.WriteLine($"Not enough money! You need {totalPrice-budget:f2} leva.");
  73. }
  74.  
  75.  
  76. }
  77.  
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement