首页 > 编程知识 正文

java string做除法JAVA 除法运算问题,java算术运算符除法

时间:2023-05-05 18:54:00 阅读:179071 作者:1151

importjavax.swing.JOptionPane; publicclasscalculatebodymassindex {//mainmethodpublicstaticvoidmain (string [ ] args (//enteraweightinkgstringtempstempstring .

import javax.swing.JOptionPane;

publicclasscalculatebodymassindex {

//主方法

publicstaticvoidmain (string [ ] args ) {

//Enter a weight in kg

string tempstring=joptionpane.showinputdialog (空,

' Enter a weight in kg ',' Input Dialog Demo ',

JOptionPane.QUESTION_MESSAGE;

//Enter a height in m

strings=(string ) joptionpane.showinputdialog (null,

' Enter a height in m ',' Input Dialog Demo ',

JOptionPane.QUESTION_MESSAGE;

//converttheinputstringintoadoublevalue

double weight=double.parse double (tempstring );

double height=double.parse double (tempstring );

//Convert it to BMI

doubleBMI=(weight/) height*height );

//Display the result

joption pane.show message dialog (null,' The BMI is ) )。

BMI ' in kg/m2 ';

() ) ) ) )。

() ) ) ) )。

=========================================================================================

不知道错在哪里。运算的结果错了.

程序计算BMI。 公式为重量/高度^2

我觉得是DOUBLE的问题。 但是,JAVA的水平有限.

不知道哪个大神会解决吗? 谢谢你。 ~

展开

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。