Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function neli(input){
- let flowerType = input[0];
- let flowersCount = Number(input[1]);
- let budget = Number(input[2]);
- let rosePrice = 5;
- let daliaPrice = 3.8;
- let lalePrice = 2.8;
- let narcisPrice = 3;
- let gladiolaPrice = 2.5;
- let total = 0.0
- switch(flowerType){
- case "Roses":
- if(flowersCount>80){
- total = rosePrice*flowersCount - (rosePrice*flowersCount*0.1)
- }else {
- total = rosePrice*flowersCount
- }
- break;
- case "Dahlias":
- if(flowersCount>90){
- total = daliaPrice*flowersCount - (daliaPrice*flowersCount*0.15)
- }else {
- total = daliaPrice*flowersCount
- }
- break;
- case "Tulips":
- if(flowersCount>80){
- total = lalePrice*flowersCount - (lalePrice*flowersCount*0.15)
- }else {
- total = lalePrice*flowersCount
- }
- break;
- case "Narcissus":
- if(flowersCount<120){
- total = narcisPrice*flowersCount + (narcisPrice*flowersCount*0.15)
- }else {
- total = narcisPrice*flowersCount
- }
- break;
- case "Gladiolus":
- if(flowersCount<80){
- total = gladiolaPrice*flowersCount + (gladiolaPrice*flowersCount*0.2)
- }else {
- total = gladiolaPrice*flowersCount
- }
- break;
- }
- if(budget >= total){
- console.log(`Hey, you have a great garden with ${flowersCount} ${flowerType} and ${(budget-total).toFixed(2)} leva left.`);
- } else {
- console.log(`Not enough money, you need ${(total - budget).toFixed(2)} leva more.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement