/* Name ... On 20/06/02 At ... */ import java.awt.*; import java.applet.*; import java.lang.*; public class fuel extends Applet { public double MilesPer1Gallon = 0; //Variable to store the result of conversion public double fuel_input = 0; public double fuel_consumption(double KilometresIn1Mile, double LitresIn1Gallon, double ConsumptionInLper100Km) { MilesPer1Gallon = (100.0 * LitresIn1Gallon) / (KilometresIn1Mile * ConsumptionInLper100Km); //Conversion formula fuel_input = ConsumptionInLper100Km; repaint(); // update the java applet screen return MilesPer1Gallon; //returns the value for the function } // draw information to applet screen public void paint(Graphics g ) { // set font face, size, weight g.setFont(new Font("TimesRoman",Font.BOLD,24)); // set font colour g.setColor(Color.red); // show user's fuel consumption g.drawString("Fuel Consumption Conversion is as follows: " , 5, 25); // show user's converted fuel consumption g.drawString(fuel_input + "(litres/100km) = " + MilesPer1Gallon + "(miles/gallon)", 5, 50); } }