5. Write a JavaScript code to input a purchase amount and calculate
the discount and net amount based on the following criteria:
Net Amount = Purchase Amount --Discount
Make use of the if..else statement.
purchase amount-- <= 5000,
>5000 and <= 10000,
>10000 discount-- 2%, 5%, 8%
Answers
Program:
import java.util.*;
class purchase{
public static voice main(String args[]) {
Scanner scan= new Scanner (System.in) ;
System.out.println("Enter purchased amount : ") ;
double amount = scan.nextDouble();
if( amount <= 5000 ) {
System.out.println(" The Discount 2% is "+ ( ( 2/100 ) * amount )) ;
System.out.println(" The Net Amount is "+(amount-( (2/100 )* amount)));
}else if( amount > 5000 && amount <= 1000 ){
System.out.println(" The Discount 5% is "+ ( ( 5/100 ) * amount )) ;
System.out.println(" The Net Amount is "+(amount-( (5/100 )* mount )));
}else if( amount > 10000 ) {
System.out.println(" The Discount 8% is "+ ( ( 8/100 ) * amount )) ;
System.out.println(" The Net Amount is "+(amount - ( ( 8/100 ) * amount )));
}
}
}
Output:
Enter purchased amount : 7500
The Discount is 5% is 375
Net amount is 7125
Explanation:
- i directly calculated discount,net_amount without assigning any variables to it.
--- Hope you got what you wanted ( mark brainliest if you like my program :)