import [Link].
*;
public class discount
public static void main()
{ Scanner sc = new Scanner( [Link] );
double total_cost=0.0, dis=0.0, net_amount=0.0;
[Link]("Input price of product = " );
double pr = sc . nextDouble();
[Link]("Input quantity purchased = " );
int qty = sc . nextInt();
total_cost = pr * qty;
if (total_cost > 2000)
dis = total_cost * 0.05;
else if (total_cost >= 2001 && total_cost <= 5000)
dis = total_cost * 0.25;
else if (total_cost >= 5001 && total_cost <= 10000)
dis = total_cost * 0.35;
else if (total_cost >= 10001)
dis = total_cost * 0.50;
net_amount = total_cost - dis;
[Link]("Output");
[Link]("Quantity of the product purchased = " + qty);
[Link]("Price of the product = " + pr);
[Link]("Total cost of the product = " + total_cost );
[Link]("Discount on total cost = " + dis);
[Link]("Net amount to be paid = " + net_amount);
Output:
Input price of product = 2
Input quantity purchased = 5
Output
Quantity of the product purchased = 5
Price of the product = 2.0
Total cost of the product = 10.0
Discount on total cost = 0.0
Net amount to be paid = 10.0