Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let buyedHrizantem = Number(input[0]);
- let buyedRoses = Number(input[1]);
- let buyedTulips = Number(input[2]);
- let season = input[3];
- let holidayYesNo = input[4];
- let totalFLowers = 0;
- let countFlowers = buyedHrizantem + buyedRoses + buyedTulips;
- if (holidayYesNo === 'Y' && (season === 'Spring' || season === 'Summer')) {
- buyedHrizantem = buyedHrizantem * 2.00;
- buyedRoses = buyedRoses * 4.10;
- buyedTulips = buyedTulips * 2.50;
- totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
- totalFLowers = totalFLowers + (totalFLowers * (15 / 100));
- if (season === 'Spring' && buyedTulips > 7) {
- totalFLowers = totalFLowers - (totalFLowers * (5 / 100));
- }
- } else if (holidayYesNo === 'N' && (season === 'Spring' || season === 'Summer')) {
- buyedHrizantem = buyedHrizantem * 2.00;
- buyedRoses = buyedRoses * 4.10;
- buyedTulips = buyedTulips * 2.50;
- totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
- if (season === 'Spring' && buyedTulips > 7) {
- totalFLowers = totalFLowers - (totalFLowers * (5 / 100));
- }
- } else if (holidayYesNo === 'Y' && (season === 'Autumn' || season === 'Winter')) {
- buyedHrizantem = buyedHrizantem * 3.75;
- buyedRoses = buyedRoses * 4.50;
- buyedTulips = buyedTulips * 4.15;
- totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
- totalFLowers = totalFLowers + (totalFLowers * (15 / 100));
- if (season === 'Winter' && buyedRoses >= 10) {
- totalFLowers = totalFLowers - (totalFLowers * (10 / 100));
- }
- } else if (holidayYesNo === 'N' && (season === 'Autumn' || season === 'Winter')) {
- buyedHrizantem = buyedHrizantem * 3.75;
- buyedRoses = buyedRoses * 4.50;
- buyedTulips = buyedTulips * 4.15;
- totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
- if (season === 'Winter' && buyedRoses >= 10) {
- totalFLowers = totalFLowers - (totalFLowers * (10 / 100));
- }
- }
- if (countFlowers > 20) {
- totalFLowers = totalFLowers - (totalFLowers * (20 / 100));
- }
- totalFLowers = totalFLowers + 2;
- console.log(totalFLowers.toFixed(2));
- }
- solve([
- '2',
- '4',
- '8',
- 'Spring',
- 'N'
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement