Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shopping(input) {
- let budget = parseFloat(input[0]);
- let gpu = parseInt(input[1]);
- let cpu = parseInt(input[2]);
- let ram = parseInt(input[3]);
- let gpuPrice = gpu * 250;
- let cpuPrice = cpu * gpuPrice * 0.35;
- let ramPrice = ram * gpuPrice * 0.10;
- let totalAmount = gpuPrice + cpuPrice + ramPrice;
- if (gpu > cpu){
- totalAmount *= 0.85;
- }
- if (budget >= totalAmount){
- console.log(`You have ${(budget - totalAmount).toFixed(2)} leva left!`);
- } else{
- console.log(`Not enough money! You need ${(totalAmount - budget).toFixed(2)} leva more!`);
- }
- }
Add Comment
Please, Sign In to add comment