收藏 分销(赏)

BMI身高体重指数计算器forAndroid.doc

上传人:仙人****88 文档编号:11767415 上传时间:2025-08-12 格式:DOC 页数:4 大小:59.04KB 下载积分:10 金币
下载 相关 举报
BMI身高体重指数计算器forAndroid.doc_第1页
第1页 / 共4页
BMI身高体重指数计算器forAndroid.doc_第2页
第2页 / 共4页


点击查看更多>>
资源描述
---------------------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">BMI身高体重指数计算器</string> </resources> ---------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="请输入您的身高:单位(米)" android:textColor="#00000F" android:textSize="20dp" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/height" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="请输入您的体重:单位(千克)" android:textColor="#00000F" android:textSize="20dp" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/weight" android:inputType="number" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BMI计算" android:textColor="#FF000F" android:id="@+id/BMIbutton" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/show" android:textColor="#0000F0" android:textSize="30dp" /> </LinearLayout> ---------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------- Package …… import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class BMIActivity extends Activity { private EditText height = null; private EditText weight = null; private Button button = null; private TextView show = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button=(Button)findViewById(R.id.BMIbutton); height=(EditText) findViewById(R.id.height); weight=(EditText) findViewById(R.id.weight); show=(TextView) findViewById(R.id.show); button.setOnClickListener(new View.OnClickListener() { double bmi=0; public void onClick(View v) { double h=new Double(height.getText().toString()); double w=new Double(weight.getText().toString()); bmi=w/(h*h); double final_resault = exchangeResault(bmi); if(bmi<18.5){ show.setText("您的身高体重指数是:"+final_resault+" "+"(⊙o⊙)哦!体重过轻,注意增加饮食!"); } else if(bmi>=18.5||bmi<24){ show.setText("您的身高体重指数是:"+final_resault+" "+"O(∩_∩)O~体重正常,继续保持!"); } else if(bmi>=24||bmi<27){ show.setText("您的身高体重指数是:"+final_resault+" "+"(~ o ~)~zZ!体重稍重,注意锻炼!"); } else if(bmi>=27||bmi<30){ show.setText("您的身高体重指数是:"+final_resault+" "+"~~o(>_<)o ~~轻度肥胖,多锻炼,注意饮食健康!"); } else if(bmi>=30||bmi<35){ show.setText("您的身高体重指数是:"+final_resault+" "+"~(@^_^@)~中度肥胖,注意饮食要节制,适当减肥!"); } else if(bmi>35){ show.setText("您的身高体重指数是:"+final_resault+" "+"(*@ο@*) 哇~重度肥胖,必须减肥,不然易患多种肥胖引起的疾病!"); } } }); } public double exchangeResault(double resault){ double first =resault*100; double second = (int) first; double second_first = first-second; if(second_first>0.5){ second++; } double jirguo = (double)second/100; return jirguo; } } ----------------------------------------------------------------------------------------------------------------------
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服