
import javax.swing.JOptionPanepublic class Test1 public static void main(String[] args) {String weightStr = JOptionPane.showInputDialog("输入体重(kg)。
大多数方案教会顾客怎样才是安全的,明智的,渐变的吃的方式。改变包括增加复合碳水化物的摄入量(水果,蔬菜,面包,谷类制品,世腔意大利面制品),并降低脂肪和简单碳水化物的摄入量。每搜茄衫天提供400~800kcal极低能量的饮食已不太流行,因为显而易见病人可快速地恢复他们的体重。
体重控制:
体重控制方案可使用4种疗法:饮食和营养咨询,行为治疗,药物和外科手术。 饮食是极少采用传统的饮食疗法;代之以强调改变长期习惯。
标准体重:标准体重的“标准”纳大各国所制定的并不完全一样。一个国家不同年龄组的标准体重通常是本国经过群体大样本的调研所得到的。
根据人的年龄、身高所计算出的各年龄组人的体重大体范围,并规定其上下界限。我国国家体委体育科研所就曾对15岁以内儿童的体重值,做过规范化研究,查看这一标准,您就会明白您孩子体重是否标准。
应用的 *** 作和原理
目标Android应用的 *** 作过程是这样的:选择你的性别,然后输入你的身高,点查看计算结果的按钮就在Toast中显示你的标准体重。力求 *** 作简单,结果显示清楚。
标准体重的计算公式:
男性:(身高cm-80)×70%=标准体重
女性:(身高cm-70)×60%=标准体重
应用的源码
BMIActivity.java:
package com.lingdududu.bmiimport java.text.DecimalFormat
import java.text.NumberFormat
import android.app.Activity
import android.os.Bundle
import 孝枯android.view.View
import android.view.View.OnClickListener
import android.widget.Button
import android.widget.EditText
import android.widget.RadioButton
import android.widget.Toast
/*
* @author lingdududu * 该程序的功能是用户选择自己的性别和输入自己的身高,然后点击按钮,就能在Toast显示出自己的标准体重
*/
public class BMIActivity extends Activity {
/** Called when the activity is first created. */
private Button countButton
private EditText heighText
private RadioButton maleBtn, femaleBtn
String sex = ""
double height
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main)
//调用创建视图的函数
creadView() 戚皮
//调用性别选择的函数
sexChoose()
//调用Button注册监听器的函数
setListener()
}
//响应Button事件的函数
private void setListener() {
countButton.setOnClickListener(countListner)
}
private OnClickListener countListner = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(BMIActivity.this, "你是一位"+sexChoose()+"\n"
+"你的身高为"+Double.parseDouble(heighText.getText().toString())+"cm"
+"\n你的标准体重为"+getWeight(sexChoose(), height)+"kg", Toast.LENGTH_LONG)
.show()
}
}
//性别选择的函数
private String sexChoose(){
if (maleBtn.isChecked()) {
sex = "男性"
}
else if(femaleBtn.isChecked()){
sex = "女性"
}
return sex
}
//创建视图的函数
public void creadView(){
//txt=(TextView)findViewById(R.id.txt)
countButton=(Button)findViewById(R.id.btn)
heighText=(EditText)findViewById(R.id.etx)
maleBtn=(RadioButton)findViewById(R.id.male)
femaleBtn=(RadioButton)findViewById(R.id.female)
//txt.setBackgroundResource(R.drawable.bg)
}
//标准体重格式化输出的函数 高慎差
private String format(double num) {
NumberFormat formatter = new DecimalFormat("0.00")
String str = formatter.format(num)
return str
}
//得到标准体重的函数
private String getWeight(String sex, double height) {
height = Double.parseDouble(heighText.getText().toString())
String weight = ""
if (sex.equals("男性")) {
weight =format((height - 80) * 0.7)
}
else {
weight = format((height - 70) * 0.6)
}
return weight
}
}
20 <= x <= 22vb不能连等 if x>李皮=? and x<=? then
Private Sub Command1_Click()
Text3.Text = Round(Val(Text2.Text / (Text1.Text) ^ 2), 2)
Dim x
Picture1.Cls
x = Val(Text3.Text)
If 20 <= x And x <= 22 Then
Picture1.Print "最佳"
ElseIf 18.5 <= x And x <20 Then
Picture1.Print "正常"
ElseIf 22 <空拆 x And x <24 Then
Picture1.Print "正常"
ElseIf x <18.5 Then
Picture1.Print "哪亏差偏瘦"
ElseIf 24 <= x And x <28 Then
Picture1.Print "超重"
Else
Picture1.Print "肥胖"
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)