Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let drinkName = String(input.shift());
- let sugarQntt = String(input.shift());
- let drinkNum = Number(input.shift());
- let totalPrice = 0;
- switch (drinkName) {
- case 'Espresso':
- switch (sugarQntt) {
- case 'Without':
- totalPrice = drinkNum * 0.90;
- break;
- case 'Normal':
- totalPrice = drinkNum * 1;
- break;
- case 'Extra':
- totalPrice = drinkNum * 1.20;
- break;
- }
- if (drinkNum > 5) {
- totalPrice *= 0.75;
- }
- break;
- case 'Cappuccino':
- switch (sugarQntt) {
- case 'Without':
- totalPrice = drinkNum * 1;
- break;
- case 'Normal':
- totalPrice = drinkNum * 1.20;
- break;
- case 'Extra':
- totalPrice = drinkNum * 1.60;
- break;
- }
- break;
- case 'Tea':
- switch (sugarQntt) {
- case 'Without':
- totalPrice = drinkNum * 0.50;
- break;
- case 'Normal':
- totalPrice = drinkNum * 0.60;
- break;
- case 'Extra':
- totalPrice = drinkNum * 0.70;
- break;
- }
- break;
- }
- if (sugarQntt === 'Without') {
- totalPrice *= 0.65;
- }
- if (totalPrice > 15) {
- totalPrice *= 0.80;
- }
- console.log(`You bought ${drinkNum} cups of ${drinkName} for ${totalPrice.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement