import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
/**
* Description of the Class
*
*@author
*@created 13. Juni 2005
*/
public class P extends Applet implements ActionListener {
private TextField eingabe1;
/**
* Description of the Field
*/
public double rabatt;
/**
* Description of the Field
*/
public double preiß;
/**
* Description of the Field
*/
public double proz = 50;
/**
* Description of the Method
*/
public void init() {
Label feld1 = new Label("Preis in Euro: ");
add(feld1);
eingabe1 = new TextField(10);
add(eingabe1);
eingabe1.addActionListener(this);
}
/**
* Description of the Method
*
*@param g Description of the Parameter
*/
public void paint(Graphics g) {
preiß = Double.parseDouble(eingabe1.getText());
System.out.println("Preis: " + preiß);
System.out.println("Proz: " + proz);
rabatt = preiß * proz / 100;
System.out.println("Rabatt: " + rabatt);
if (rabatt >= 1) {
g.drawString("Lohnt sich", 50, 50);
} else {
g.drawString("Lohnt sich nicht", 50, 50);
}
}
/**
* Description of the Method
*
*@param event Description of the Parameter
*/
public void actionPerformed(ActionEvent event) {
Double temp1 = Double.valueOf(eingabe1.getText());
// rabatt = temp1.doubleValue();
repaint();
}
}