0
我想要正確地格式化java程序的輸出。該程序似乎無法正常工作。在Java窗格中格式化輸出
[代碼]
import javax.swing.JOptionPane;
public class Exercise4 {
public static void main(String[] args) {
double weight;
double height;
double bmi;
String input;
// Get users's weight.
input = JOptionPane.showInputDialog("Enter your weight.");
weight = Double.parseDouble(input);
//Get users's height
input = JOptionPane.showInputDialog("Enter your height in inches.");
height = Double.parseDouble(input);
bmi = weight * (703/Math.pow(height, 2.0));
JOptionPane.showMessageDialog(null, "Your BMI is " + bmi);
}
}
[/代碼]
你試圖達到什麼樣的格式? –
小數點右側不得超過2個位置 – MikeinFl