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
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
Science,
5 months ago
Business Studies,
5 months ago
English,
5 months ago
Science,
11 months ago
Chemistry,
11 months ago
Social Sciences,
1 year ago
Chemistry,
1 year ago