Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function flowers(input) {
- let chrisanthemumQty = Number(input[0]);
- let rosesQty = Number(input[1]);
- let tulipsQty = Number(input[2]);
- let season = input[3];
- let holiday = input[4];
- let chrisanthemumPrice = 0;
- let rosesPrice = 0;
- let tulipsPrice = 0;
- if (holiday === "N") {
- switch (season) {
- case "Spring":
- case "Summer":
- chrisanthemumPrice = chrisanthemumQty * 2;
- rosesPrice = rosesQty * 4.10;
- tulipsPrice = tulipsQty * 2.50;
- break;
- case "Autumn":
- case "Winter":
- chrisanthemumPrice = chrisanthemumQty * 3.75;
- rosesPrice = rosesQty * 4.50;
- tulipsPrice = tulipsQty * 4.15;
- break;
- }
- }
- if (holiday === "Y") {
- switch (season) {
- case "Spring":
- case "Summer":
- chrisanthemumPrice = (chrisanthemumQty * 2) * 1.15;
- rosesPrice = (rosesQty * 4.10) * 1.15;
- tulipsPrice = (tulipsQty * 2.50) * 1.15;
- break;
- case "Autumn":
- case "Winter":
- chrisanthemumPrice = (chrisanthemumQty * 3.75 * 1.15);
- rosesPrice = (rosesQty * 4.50) * 1.15;
- tulipsPrice = (tulipsQty * 4.15) * 1.15;
- break;
- }
- }
- let bouquetPrice = chrisanthemumPrice + rosesPrice + tulipsPrice;
- if (season === "Spring" && tulipsQty > 7) {
- bouquetPrice = bouquetPrice * 0.95;
- }
- if (season === "Winter" && rosesQty >= 10) {
- bouquetPrice = bouquetPrice * 0.90;
- }
- if ((chrisanthemumQty + rosesQty + tulipsQty) > 20) {
- bouquetPrice = bouquetPrice * 0.80;
- }
- console.log((bouquetPrice + 2).toFixed(2));
- }
Advertisement
Add Comment
Please, Sign In to add comment