I have this chunk of code. It's a simple BMI calculator, but I've noticed that I can only enter whole numbers into my textfields. What can I do to allow decimals?
import java.applet.*; import java.awt.*; import java.awt.event.*; public class BMICALC extends Applet implements ActionListener { int in, lbs; double m, kg, bmi; Label titleLabel = new Label ("Body Mass Index Calculator"); // Label hLabel = new Label ("Enter your height in inches: "); TextField hField = new TextField(10); // Label wLabel = new Label ("Enter your weight in pounds: "); TextField wField = new TextField(10); // Button bmiButton = new Button("Calculate"); Label oLabel = new Label ("Click Calculate to see your body mass index."); public void init() { setForeground(Color.white); setBackground(Color.black); add(titleLabel); add(hLabel); setForeground(Color.black); add(hField); setForeground(Color.white); add(wLabel); setForeground(Color.black); add(wField); add(bmiButton); setForeground(Color.white); bmiButton.addActionListener(this); setForeground(Color.green); add(oLabel); } public void actionPerformed(ActionEvent k) { in = Integer.parseInt(hField.getText()); lbs = Integer.parseInt(wField.getText()); m = in / 39.36; kg = lbs / 2.2; bmi = kg / Math.pow(m,2); oLabel.setText("Your body mass index is " + Math.round(bmi) + "."); } }