-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRetailItemPrice.java
More file actions
74 lines (52 loc) · 1.67 KB
/
RetailItemPrice.java
File metadata and controls
74 lines (52 loc) · 1.67 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package GUI;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class RetailItemPrice extends JFrame {
private JPanel jPanel;
private JLabel wholeSale;
private JLabel markUp;
private JTextField f1;
private JTextField f2;
private JButton retailPrice;
private JButton jButton;
public RetailItemPrice(){
setTitle("Retail Price");
setSize(300,200);
build();
add(jPanel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public void build(){
wholeSale = new JLabel("Whole sale cost :");
markUp = new JLabel("markup percentage :");
f1 = new JTextField(10);
f2 = new JTextField(10);
retailPrice = new JButton("Retail Price");
jButton = new JButton(" ");
retailPrice.addActionListener(new RListener());
jPanel = new JPanel();
jPanel.add(wholeSale);
jPanel.add(f1);
jPanel.add(markUp);
jPanel.add(f2);
jPanel.add(retailPrice);
jPanel.add(jButton);
}
private class RListener implements ActionListener{
public void actionPerformed(ActionEvent e){
String input;
double whole,mark,price;
input = f1.getText();
whole = Double.parseDouble(input);
input = f2.getText();
mark = Double.parseDouble(input) / 100;
price = whole * mark;
JOptionPane.showMessageDialog(null,"retail price : " + price);
}
}
public static void main(String[] args) {
new RetailItemPrice();
}
}