/*
Chapter 3:
Chapter Walk Through part2
Programmer:
Brad Shedd
Date:
April 19, 2006
Filename:
BillsBurgersApplet.java
Purpose:
This project calculates person's bill
from ordering
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
public
class
BillsBurgersApplet
extends Applet
implements
ActionListener
{
// delare
variables
Image image;
// declare
an Image object
double
order,tax, total;
//constuct
components
Label orderLabel
=
new
Label("Enter the price of the order:
");
TextField orderField =
new
TextField(10);
Button calcButton =
new
Button("Calculate");
Label outputLabel =
new
Label ("Click Calculate to display sales");
public
void init()
{
add(orderLabel);
add(orderField);
calcButton.addActionListener(this);
add(calcButton);
add(outputLabel);
image = getImage(getDocumentBase(),
"image.jpg");
}
//
end of init method
public
void actionPerformed(ActionEvent e)
{
order = Double.parseDouble(orderField.getText());
tax = order * 0.07;
total = tax + order;
outputLabel.setText ("Order:
" + (order) +
" Sales Tax:
" + (tax) +
" Total Sale:
" + (total));
}
public
void paint(Graphics g)
{
g.drawImage(image,45,110,this);
}
}
// end of BillsBurgersApplet class