-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriceDiscount.java
More file actions
31 lines (22 loc) · 782 Bytes
/
PriceDiscount.java
File metadata and controls
31 lines (22 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import javax.swing.JOptionPane;
public class PriceDiscount
{
public static void main(String[] args)
{
String sPrice, sDiscount;
double price;
int discount;
sPrice = JOptionPane.showInputDialog(null, "Regular Price: ");
price = Double.parseDouble(sPrice);
sDiscount = JOptionPane.showInputDialog(null, "Discount %: ");
discount = Integer.parseInt(sDiscount);
compute(price,discount);
}
public static void compute(double price, int discount)
{
double total, ded;
ded = price * ((double)discount/100);
total = price - ded;
JOptionPane.showMessageDialog(null, "Discounted Price: "+ total);
}
}