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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
| btnConvert.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnConvert.setBounds(43, 226, 107, 31);
panel_1.add(btnConvert);
JButton btnClose = new JButton("Close");
btnClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
comboBox_1.setSelectedItem("Choose Country");
textField_5.setText(null);
label_5.setText(null);
}
});
btnClose.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnClose.setBounds(207, 226, 107, 31);
panel_1.add(btnClose);
JLabel label_4 = new JLabel("");
label_4.setHorizontalAlignment(SwingConstants.RIGHT);
label_4.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_4.setBorder(new LineBorder(new Color(0, 0, 0), 2));
label_4.setBounds(77, 150, 205, 29);
panel_1.add(label_4);
JPanel panel_2 = new JPanel();
panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 8));
panel_2.setBounds(34, 420, 535, 175);
frame.getContentPane().add(panel_2);
panel_2.setLayout(null);
JLabel lblCostOfDrinks = new JLabel("Cost of Drinks");
lblCostOfDrinks.setFont(new Font("Tahoma", Font.PLAIN, 24));
lblCostOfDrinks.setBounds(22, 23, 168, 29);
panel_2.add(lblCostOfDrinks);
JLabel lblCostOfMeal = new JLabel("Cost of Meal");
lblCostOfMeal.setFont(new Font("Tahoma", Font.PLAIN, 24));
lblCostOfMeal.setBounds(22, 74, 224, 29);
panel_2.add(lblCostOfMeal);
JLabel lblCostOf = new JLabel("Cost of Delivery");
lblCostOf.setFont(new Font("Tahoma", Font.PLAIN, 24));
lblCostOf.setBounds(22, 124, 182, 29);
panel_2.add(lblCostOf);
JLabel label_1 = new JLabel("");
label_1.setHorizontalAlignment(SwingConstants.RIGHT);
label_1.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_1.setBounds(256, 23, 256, 29);
label_1.setBorder(new LineBorder(new Color(0, 0, 0), 2));
panel_2.add(label_1);
JLabel label_2 = new JLabel("");
label_2.setHorizontalAlignment(SwingConstants.RIGHT);
label_2.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_2.setBorder(new LineBorder(new Color(0, 0, 0), 2));
label_2.setBounds(256, 74, 256, 29);
panel_2.add(label_2);
JLabel label_3 = new JLabel("");
label_3.setHorizontalAlignment(SwingConstants.RIGHT);
label_3.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_3.setBorder(new LineBorder(new Color(0, 0, 0), 2));
label_3.setBounds(256, 124, 256, 29);
panel_2.add(label_3);
JPanel panel_3 = new JPanel();
panel_3.setBorder(new LineBorder(new Color(0, 0, 0), 8));
panel_3.setBounds(579, 420, 350, 175);
frame.getContentPane().add(panel_3);
panel_3.setLayout(null);
JLabel label_Tax = new JLabel("");
label_Tax.setBounds(158, 23, 160, 29);
label_Tax.setHorizontalAlignment(SwingConstants.RIGHT);
label_Tax.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_Tax.setBorder(new LineBorder(new Color(0, 0, 0), 2));
panel_3.add(label_Tax);
JLabel label_Sub_Total = new JLabel("");
label_Sub_Total.setBounds(158, 74, 160, 29);
label_Sub_Total.setHorizontalAlignment(SwingConstants.RIGHT);
label_Sub_Total.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_Sub_Total.setBorder(new LineBorder(new Color(0, 0, 0), 2));
panel_3.add(label_Sub_Total);
JLabel label_Total = new JLabel("");
label_Total.setBounds(158, 121, 160, 29);
label_Total.setHorizontalAlignment(SwingConstants.RIGHT);
label_Total.setFont(new Font("Tahoma", Font.PLAIN, 24));
label_Total.setBorder(new LineBorder(new Color(0, 0, 0), 2));
panel_3.add(label_Total);
JLabel lblTax = new JLabel("Tax");
lblTax.setBounds(27, 23, 110, 29);
lblTax.setFont(new Font("Tahoma", Font.PLAIN, 24));
panel_3.add(lblTax);
JLabel lblSubTotal = new JLabel("Sub Total");
lblSubTotal.setBounds(27, 74, 110, 29);
lblSubTotal.setFont(new Font("Tahoma", Font.PLAIN, 24));
panel_3.add(lblSubTotal);
JLabel lblTotal = new JLabel("Total");
lblTotal.setBounds(27, 121, 110, 29);
lblTotal.setFont(new Font("Tahoma", Font.PLAIN, 24));
panel_3.add(lblTotal);
JPanel panel_4 = new JPanel();
panel_4.setBorder(new LineBorder(new Color(0, 0, 0), 8));
panel_4.setBounds(940, 101, 381, 494);
frame.getContentPane().add(panel_4);
panel_4.setLayout(null);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(32, 23, 339, 449);
panel_4.add(tabbedPane);
JPanel panel_6 = new JPanel();
tabbedPane.addTab("Receipt", null, panel_6, null);
panel_6.setLayout(null);
textField_3 = new JTextField();
textField_3.setEditable(false);
textField_3.setHorizontalAlignment(SwingConstants.CENTER);
textField_3.setBounds(10, 11, 314, 399);
panel_6.add(textField_3);
textField_3.setColumns(10);
JPanel panel_7 = new JPanel();
tabbedPane.addTab("Calculator", null, panel_7, null);
JPanel panel_5 = new JPanel();
panel_5.setBorder(new LineBorder(new Color(0, 0, 0), 8));
panel_5.setBounds(34, 606, 1287, 112);
frame.getContentPane().add(panel_5);
panel_5.setLayout(null);
JButton btnTotal = new JButton("Total");
btnTotal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//-----------------------Client choices + price calculation-------------------------------
double ChicBurger = Double.parseDouble(textField.getText());
double iChicBurger = 2.39;
double Burger;
Burger = (ChicBurger * iChicBurger);
String pMeal = String.format("%.2f", Burger);
label_2.setText(pMeal);
double ChicBurgerMeal = Double.parseDouble(textField_1.getText());
double iChicBurgerMeal = 4.39;
double BurgerMeal = 2.39;
BurgerMeal = (ChicBurgerMeal * iChicBurgerMeal);
String cbMeal = String.format("%.2f", BurgerMeal + Burger);
label_2.setText(cbMeal);
double CheeseBurger = Double.parseDouble(textField_2.getText());
double CheeseBurgerPrice = 3.39;
double CheeseBurgerMeal;
CheeseBurgerMeal = (CheeseBurger * CheeseBurgerPrice);
String cheese = String.format("%.2f", CheeseBurgerMeal + BurgerMeal + Burger);
label_2.setText(cheese);
//-------------Home Delivery----------------------------------
double iDelivery = 3.39;
if (chckbxHomeDelivery.isSelected())
{
String pDelivery = String.format("%.2f", iDelivery);
label_3.setText(pDelivery);
}
else
{
label_3.setText("0");
}
//-------------Drinks----------------------------------------------------------
double Drinks = Double.parseDouble(textField_4.getText());
double Apple_Juice = 2.10 * Drinks;
double Carrot_Juice = 2.30 * Drinks;
double Orange_Juice = 1.90 * Drinks;
double Pineapple_Juice = 2.40 * Drinks;
double Pomegranate_Juice = 2.30 * Drinks;
double Raspberry_Juice = 1.80* Drinks;
double Strawberry_Juice = 1.70 * Drinks;
double Tomato_Juice = 1.49 * Drinks;
double Tea = 1.20 * Drinks;
double Cola = 2.10 * Drinks;
double Coffee = 2.50 * Drinks;
double Lemonade = 1.20 * Drinks;
double Ice_Tea = 1.40 * Drinks;
double Ice_Coffee = 1.10 * Drinks;
if (comboBox.getSelectedItem().equals("Apple Juice"))
{
String cApple_Juice = String.format("%.2f", Apple_Juice);
label_1.setText(cApple_Juice);
}
if (comboBox.getSelectedItem().equals("Carrot Juice"))
{
String cCarrot_Juice = String.format("%.2f", Carrot_Juice);
label_1.setText(cCarrot_Juice);
}
if (comboBox.getSelectedItem().equals("Orange Juice"))
{
String cOrange_Juice = String.format("%.2f", Orange_Juice);
label_1.setText(cOrange_Juice);
}
if (comboBox.getSelectedItem().equals("Pineapple Juice"))
{
String cPineapple_Juice = String.format("%.2f", Pineapple_Juice);
label_1.setText(cPineapple_Juice);
}
if (comboBox.getSelectedItem().equals("Pomegranate Juice"))
{
String cPomegranate_Juice = String.format("%.2f", Pomegranate_Juice);
label_1.setText(cPomegranate_Juice);
}
if (comboBox.getSelectedItem().equals("Raspberry Juice"))
{
String cRaspberry_Juice = String.format("%.2f", Raspberry_Juice);
label_1.setText(cRaspberry_Juice);
}
if (comboBox.getSelectedItem().equals("Strawberry Juice"))
{
String cStrawberry_Juice = String.format("%.2f", Strawberry_Juice);
label_1.setText(cStrawberry_Juice);
}
if (comboBox.getSelectedItem().equals("Tomato Juice"))
{
String cTomato_Juice = String.format("%.2f", Tomato_Juice);
label_1.setText(cTomato_Juice);
}
if (comboBox.getSelectedItem().equals("Tea"))
{
String cTea = String.format("%.2f", Tea);
label_1.setText(cTea);
}
if (comboBox.getSelectedItem().equals("Cola"))
{
String cCola = String.format("%.2f", Cola);
label_1.setText(cCola);
}
if (comboBox.getSelectedItem().equals("Coffee"))
{
String cCoffee = String.format("%.2f", Coffee);
label_1.setText(cCoffee);
}
if (comboBox.getSelectedItem().equals("Lemonade"))
{
String cLemonade = String.format("%.2f", Lemonade);
label_1.setText(cLemonade);
}
if (comboBox.getSelectedItem().equals("Ice Tea"))
{
String cIce_Tea = String.format("%.2f", Ice_Tea);
label_1.setText(cIce_Tea);
}
if (comboBox.getSelectedItem().equals("Ice_Coffee"))
{
String cIce_Coffee = String.format("%.2f", Ice_Coffee);
label_1.setText(cIce_Coffee);
}
if (comboBox.getSelectedItem().equals("Select a drink"))
{
label_1.setText("0");
}
double cTotal1 = Double.parseDouble(label_1.getText()); //drinks
double cTotal2 = Double.parseDouble(label_2.getText()); //meal
double cTotal3 = Double.parseDouble(label_3.getText()); //delivery
double AllTotal = (cTotal1+cTotal2+cTotal3)/100;
if(chckbxTax.isSelected())
{
String iTotal = String.format("%.2f", AllTotal);
label_Tax.setText(iTotal);
}
//-------------------------Total-----------------------------
double cTotal4 = Double.parseDouble(label_Tax.getText());
double subTotal = (cTotal1+cTotal2+cTotal3);
String iSubTotal = String.format("$ %.2f", subTotal);
label_Sub_Total.setText(iSubTotal);
double allTotal = (cTotal1 + cTotal2 + cTotal3 + cTotal4);
String iTotal = String.format("$ %.2f", allTotal);
label_Total.setText(iTotal);
String iTaxTotal = String.format("$ %.2f", cTotal4);
label_Tax.setText(iTaxTotal);
}
});
btnTotal.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnTotal.setBounds(356, 42, 114, 36);
panel_5.add(btnTotal);
JButton btnReceipt = new JButton("Receipt");
btnReceipt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
double Qty1 = Double.parseDouble(textField.getText());
double Qty2 = Double.parseDouble(textField_1.getText());
double Qty3 = Double.parseDouble(textField_2.getText());
textField_3.setText("Restaurants Management Systems" + "Chicken Burger:"
+ Qty1 + "Chicken Burger Meal:\n"
+ Qty2 + "Bacon and Cheese Burger:\n"
+ Qty3 + "Thanks for using our service\n");
}
});
btnReceipt.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnReceipt.setBounds(521, 42, 122, 36);
panel_5.add(btnReceipt);
JButton btnReset = new JButton("Reset");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
textField.setText(null);
textField_1.setText(null);
textField_2.setText(null);
textField_3.setText(null);
textField_4.setText(null);
textField_5.setText(null);
comboBox.setSelectedItem("Select a drink");
comboBox_1.setSelectedItem("Choose Country");
chckbxTax.setSelected(false);
chckbxHomeDelivery.setSelected(false);
label_2.setText(null);
label_3.setText(null);
label_Tax.setText(null);
label_Sub_Total.setText(null);
label_Total.setText(null);
label_4.setText(null);
label_1.setText(null);
}
});
btnReset.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnReset.setBounds(688, 42, 114, 36);
panel_5.add(btnReset);
JButton btnExit = new JButton("Exit");
btnExit.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
System.exit(0);
}
});
btnExit.setBounds(845, 42, 114, 36);
panel_5.add(btnExit);
JLabel lblNewLabel = new JLabel("Loan Management Systems");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 70));
lblNewLabel.setBounds(34, 11, 1287, 85);
frame.getContentPane().add(lblNewLabel);
}
} |