Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. function solve(input){
  2. let groupBudget = Number(input.shift());
  3. let season = input.shift();
  4. let fishersCount = Number(input.shift());
  5.  
  6.  
  7. let currentPrice = 0;
  8. let finalCurrentPrice = 0;
  9. let price = 0;
  10.  
  11.  
  12. if (season === "Spring") {
  13. if(fishersCount <= 6){
  14. currentPrice = 3000 - 3000 * 0.10;
  15.  
  16. }else if( fishersCount >= 7 && fishersCount <= 11){
  17. currentPrice = 3000 - 3000 * 0.15;
  18.  
  19. }else if(fishersCount >= 12){
  20. currentPrice = 3000 - 3000 * 0.25;
  21. }
  22. price = currentPrice - groupBudget;
  23. } else if (season === "Summer") {
  24. if(fishersCount <= 6){
  25. currentPrice = 4200 - 4200 * 0.10;
  26.  
  27. }else if( fishersCount >= 7 && fishersCount <= 11){
  28. currentPrice = 4200 - 4200 * 0.15;
  29. }else if(fishersCount >= 12){
  30. currentPrice = 4200 - 4200 * 0.25;
  31. }
  32. price = currentPrice - groupBudget;
  33.  
  34. }
  35. else if (season === "Winter") {
  36. if (fishersCount <= 6){
  37. currentPrice = 2600 - 2600 * 0.10;
  38. }else if( fishersCount >= 7 && fishersCount <= 11){
  39. currentPrice = 2600 - 2600 *0.15;
  40. }else if(fishersCount >=12){
  41. currentPrice = 2600 - 2600 * 0.20;
  42. }
  43. price = currentPrice - groupBudget;
  44.  
  45. } else if (season === " Autumn") {
  46. if (fishersCount <= 6){
  47. currentPrice = 4200 - 4200 * 0.10;
  48. }else if( fishersCount >= 7 && fishersCount <= 11){
  49. currentPrice = 4200 - 4200 * 0.15;
  50. }else if(fishersCount >=12){
  51. currentPrice = 4200 - 4200 * 0.20;
  52. }
  53. price = currentPrice - groupBudget;
  54. }
  55. if (fishersCount % 2 === 0 && season !== "Autumn") {
  56. finalCurrentPrice = price - (price * 0.05);
  57. } else {
  58.  
  59. finalCurrentPrice = price;
  60. }
  61.  
  62. if(finalCurrentPrice >= groupBudget){
  63. console.log(`Yes! You have ${finalCurrentPrice.toFixed(2)} leva left.`)
  64. }else{
  65.  
  66. console.log(`Not enough money! You need ${Math.abs(finalCurrentPrice).toFixed(2)} leva.`)
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement