import java.awt.* ;
import java.awt.event.*;
public class percentFat extends Frame implements ActionListener
{
Label title = new Label("Percent of Calories from Fat");
Label fatLabel = new Label("Enter grams of fat: ");
Label calLabel = new Label("Enter total calories: ");
Label perLabel = new Label("Percent calories from fat: ");
TextField inFat = new TextField( 7 );
TextField inCal = new TextField( 7 );
TextField outPer = new TextField( 7 );
Button doit = new Button("Do It!");
int calories ; // input from the user: total calories per serving
int fatGrams ; // input from the user: grams of fat per serving
double percent ; // result: percent of calories from fat
percentFat() // constructor
{
outPer.setEditable( false );
doit.addActionListener( this );
}
. . . . .
|