Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function demo(input) {
- let budget = Number(input[0])
- let season = input[1]
- let people = Number(input[2])
- let total = 0;
- if(season == "Spring"){
- if(people <= 6){
- total = 3000 * 0.90
- }
- else if(people > 6 && people <= 11){
- total = 3000 * 0.85
- }
- else{
- total = 3000 * 0.75
- }
- }
- else if( season == "Summer" || season == "Autumn"){
- if(people <= 6){
- total = 4200 * 0.90
- }
- else if(people > 6 && people <= 11){
- total = 4200 * 0.85
- }
- else{
- total = 4200 * 0.75
- }
- }
- else if( season == "Winter"){
- if(people <= 6){
- total = 2600 * 0.90
- }
- else if(people > 6 && people <= 11){
- total = 2600 * 0.85
- }
- else{
- total = 2600 * 0.75
- }
- }
- if( season !== "Autumn"){
- if(people % 2 == 0){
- total = total * 0.95
- }
- }
- let moneyLeft = budget - total;
- if(moneyLeft >= 0){
- console.log(`Yes! You have ${moneyLeft.toFixed(2)} leva left.`);
- }
- else {
- console.log(`Not enough money! You need ${(moneyLeft * -1).toFixed(2)} leva.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement