Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input){
- let groupBudget = Number(input.shift());
- let season = input.shift();
- let fishersCount = Number(input.shift());
- let currentPrice = 0;
- let finalCurrentPrice = 0;
- let price = 0;
- if (season === "Spring") {
- if(fishersCount <= 6){
- currentPrice = 3000 - 3000 * 0.10;
- }else if( fishersCount >= 7 && fishersCount <= 11){
- currentPrice = 3000 - 3000 * 0.15;
- }else if(fishersCount >= 12){
- currentPrice = 3000 - 3000 * 0.25;
- }
- price = currentPrice - groupBudget;
- } else if (season === "Summer") {
- if(fishersCount <= 6){
- currentPrice = 4200 - 4200 * 0.10;
- }else if( fishersCount >= 7 && fishersCount <= 11){
- currentPrice = 4200 - 4200 * 0.15;
- }else if(fishersCount >= 12){
- currentPrice = 4200 - 4200 * 0.25;
- }
- price = currentPrice - groupBudget;
- }
- else if (season === "Winter") {
- if (fishersCount <= 6){
- currentPrice = 2600 - 2600 * 0.10;
- }else if( fishersCount >= 7 && fishersCount <= 11){
- currentPrice = 2600 - 2600 *0.15;
- }else if(fishersCount >=12){
- currentPrice = 2600 - 2600 * 0.20;
- }
- price = currentPrice - groupBudget;
- } else if (season === " Autumn") {
- if (fishersCount <= 6){
- currentPrice = 4200 - 4200 * 0.10;
- }else if( fishersCount >= 7 && fishersCount <= 11){
- currentPrice = 4200 - 4200 * 0.15;
- }else if(fishersCount >=12){
- currentPrice = 4200 - 4200 * 0.20;
- }
- price = currentPrice - groupBudget;
- }
- if (fishersCount % 2 === 0 && season !== "Autumn") {
- finalCurrentPrice = price - (price * 0.05);
- } else {
- finalCurrentPrice = price;
- }
- if(finalCurrentPrice >= groupBudget){
- console.log(`Yes! You have ${finalCurrentPrice.toFixed(2)} leva left.`)
- }else{
- console.log(`Not enough money! You need ${Math.abs(finalCurrentPrice).toFixed(2)} leva.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement