Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function flowers (input) {
- let boughtHrizantems = Number(input[0]);
- let boughtRoses = Number(input[1]);
- let boughtTulips = Number(input[2]);
- let season = input[3];
- let ifHoliday = input[4];
- let totalPrice = 0
- let priceHriz = 0;
- let priceRoses = 0
- let priceTulip = 0;
- if (season == 'Spring' || season == 'Summer') {
- priceHriz = 2.00;
- priceRoses = 4.10
- priceTulip = 2.50;
- totalPrice = boughtHrizantems * priceHriz + boughtRoses * priceRoses + boughtTulips * priceTulip;
- if (ifHoliday =='Y') {
- totalPrice *= 1.15;
- }
- if (season == 'Spring' && boughtTulips > 7) {
- totalPrice *= 0.95;
- }
- if (boughtHrizantems + boughtRoses + boughtRoses > 20) {
- totalPrice *= 0.80;
- }
- totalPrice += 2;
- } else if (season == 'Autumn' || season == 'Winter') {
- priceHriz = 3.75;
- priceRoses = 4.50;
- priceTulip = 4.15;
- totalPrice = boughtHrizantems * priceHriz + boughtRoses * priceRoses + boughtTulips * priceTulip;
- if (ifHoliday =='Y') {
- totalPrice *= 1.15;
- }
- if (boughtRoses >= 10 && season == 'Winter') {
- totalPrice *= 0.90;
- }
- if (boughtHrizantems + boughtRoses + boughtRoses > 20) {
- totalPrice *= 0.80;
- }
- totalPrice += 2;
- }
- console.log(totalPrice.toFixed(2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement