Java Reference
In-Depth Information
bill.append("\n");
bill.append("SUB TOTAL\t\t$"
+ String.format("%.2f", subTotal) + "\n");
bill.append("TAX \t\t$"
+ String.format("%.2f", tax) + "\n");
bill.append("TOTAL \t\t$"
+ String.format("%.2f", total) + "\n\n");
bill.append("Thank you - Have a Nice Day\n\n");
//reset the list array
yourChoices.clearSelection();
repaint();
}
The program listing is as follows:
//A la Carte
import
java.awt.*;
import
java.awt.event.*;
import
javax.swing.*;
import
javax.swing.event.*;
public class
AlaCarte
extends
JFrame
implements
ActionListener
{
static
String[] yourChoicesItems =
{"Blueberry Muffin
1.45",
"Strawberry Bagel
0.80",
"Lite Yogurt
0.75",
"Vanilla Ice Cream
2.75",
"Hash Browns
2.50",
"Toast
2.00",
"French Fries
1.50",
"Onion Soup
3.00",
"Coffee
0.90",
"Iced Tea
1.00",
"Hot Chocolate
1.75"};
static double
[] yourChoicesPrices = {1.45, 0.80, 0.75, 2.75,
2.50, 2.00, 1.50, 3.00,
0.90, 1.00, 1.75};
private
JList yourChoices;
private
JTextArea
bill;
private
Container pane;
Search WWH ::
Custom Search