import java.awt.*; public class ShowWeight2 extends javax.swing.JApplet { float lbs = (float)0; float idealWeight; float ozs; float kgs; float metricTons; String name = "somebody"; public void init() { String lbsValue = getParameter("weight"); if (lbsValue != null) { Float lbsTemp = Float.valueOf(lbsValue); lbs = lbsTemp.floatValue(); } String personValue = getParameter("person"); if (personValue != null) name = personValue; String idealWeightValue = getParameter("idealweight"); if (idealWeightValue != null) { Float idealWeightTemp = Float.valueOf(idealWeightValue); idealWeight = idealWeightTemp.floatValue(); } ozs = (float)(lbs * 16); kgs = (float)(lbs / 2.204623); metricTons = (float)(lbs / 2204.623); } public void paint(Graphics screen) { super.paint(screen); Graphics2D screen2D = (Graphics2D) screen; screen2D.drawString("Studying the weight of " + name, 5, 30); screen2D.drawString("In pounds: " + lbs, 55, 50); screen2D.drawString("In ounces: " + ozs, 55, 70); screen2D.drawString("In kilograms: " + kgs, 55, 90); screen2D.drawString("In metric tons: " + metricTons, 55, 110); if (idealWeight < lbs) { screen2D.drawString("Ideal weight: " + idealWeight, 55, 130); screen2D.drawString("Weeks of dieting needed: " + ((lbs - idealWeight) / 5), 55, 150); } } }