0% found this document useful (0 votes)
4 views2 pages

Java Discount Calculator Program

The Java program calculates the total cost, discount, and net amount for a product based on its price and quantity purchased. Discounts are applied based on the total cost thresholds, with varying percentages for different ranges. The program outputs the quantity, price, total cost, discount, and net amount to be paid.

Uploaded by

ramkrishna11619
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Java Discount Calculator Program

The Java program calculates the total cost, discount, and net amount for a product based on its price and quantity purchased. Discounts are applied based on the total cost thresholds, with varying percentages for different ranges. The program outputs the quantity, price, total cost, discount, and net amount to be paid.

Uploaded by

ramkrishna11619
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like