使用JOptionPane计算BMI

时间:2016-05-11 10:57:25

标签: java

我刚刚开始使用java进行编程,我正在尝试使用JOptionPane创建一个计算bmi的程序,该程序似乎运行正常,但由于某种原因,我的消息对话框不会出现,它确实是如果你可以帮助我,那就很沮丧和生病了

String weightstring = JOptionPane.showInputDialog("enter your weight in pounds:");
    Double weight =Double.parseDouble(weightstring);
    String heightstring = JOptionPane.showInputDialog("enter your height in inches:");
    Double height =Double.parseDouble("heightstring");
    final Double KGPERPOUND = 0.45359237;
    final Double METRESPERINCH  =0.0254 ;
    Double weightkg = weight* KGPERPOUND ;
    Double heightmetres= height*METRESPERINCH ;
    Double BMI = weightkg /(heightmetres*heightmetres);
    String output= "your BMi is "+BMI;
    JOptionPane.showMessageDialog(null,output);
    if (BMI<16)
        JOptionPane.showMessageDialog(null,"you are seriously underweight get something to eat:");
    else if (BMI<18)
        JOptionPane.showMessageDialog(null,"you are underweight try eating  more:");
    else if(BMI < 24)
     JOptionPane.showMessageDialog(null,"you are normal weight ,perfecto A+:");
    else if (BMI<29)
        JOptionPane.showMessageDialog(null,"you are seriously overweight fatso:");
    else if (BMI<35)
        JOptionPane.showMessageDialog(null,"you are seriously overwight n thats putting it nicely:");
    else
        JOptionPane.showMessageDialog(null,"you are gravely overweight theres nno hope for you u should probably kill yourself:");

0 个答案:

没有答案