Computer Science, asked by sanjaykumarsanjay059, 7 months ago


5. Write a JavaScript code to input a purchase amount and calculatethe discount and net amount based on the following criteria
Net Amount =PurchaseAmount - Discount
Make use of the if..else statement.
<=5000
>5000 and <= 10000
>10000
Discount
2%
5%
8%​

Answers

Answered by DrNykterstein
3

var purchase_amount = prompt();

var discount = 0;

if ( purchase_amount <= 5000){

discount = 2;

} else if ( purchase_amount > 5000 && purchase_amount <= 10000 ){

discount = 5;

} else if ( purchase_amount > 10000 ){

discount = 8;

}

var net_amt = purchase_amount - Math.floor( (discount/100) * purchase_amount);

console.log(net_amt);

Similar questions