英尺转换米
import javax.swing.JOptionPane; public class Foot { public static void main(String[] srgs){ String input = JOptionPane.showInputDialog(null,"请输入米数:","输入框",JOptionPane.QUESTION_MESSAGE); double feet = Double.parseDouble(input); System.out.println(feet + " feet is " + feet * 0.305 +" meters "); } }
编写程序,读入英尺数,将其转换为米数并显示结果。一英尺等于0.305米。