你的公式不对a/(b2),我帮你改成a/(b16),看起来差不多,实际公式是a=b-105是标准身材。 Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single
a = Val(Text1)
b = Val(Text2)
c = Round(a / (b 16))
Label6Caption = c
If Option1Value Then
If c < 20 Then
Label8Caption = "过轻"
ElseIf c < 25 Then
Label8Caption = "适中"
ElseIf c < 30 Then
Label8Caption = "过重"
ElseIf c < 35 Then
Label8Caption = "肥胖"
ElseIf c >= 35 Then
Label8Caption = "非常肥胖"
End If
Else
If c < 19 Then
Label8Caption = "过轻"
ElseIf c < 24 Then
Label8Caption = "适中"
ElseIf c < 29 Then
Label8Caption = "过重"
ElseIf c < 34 Then
Label8Caption = "肥胖"
ElseIf c >= 34 Then
Label8Caption = "非常肥胖"
End If
End If
End Sub
性别分层随机抽样,则组成此参赛队的概率为
#第一题:
from __future__ import division
print '请依次输入体重(kg)与身高(m):'
weight = float(raw_input())
height = float(raw_input())
print "{:2f}"format(weight/(height2))
#第二题:
print '请输入一个秒数:'
sec = int(raw_input())
print str(sec/3600)+' '+str(sec%3600/60)+' '+str(sec%60)
#第三题:
from __future__ import division
import math
print '请依次输入三角形三边值a, b ,c:'
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
print "{:1f}"format(mathdegrees(mathacos((a2 + b2 - c2)/(2ab))))
你复制的 问题还复制不全,汗啊。。。这么多问题 连个分也没有。。。人家计算BMI是用的平方,你这里还给了个错的公式,还能不能认真点儿。
#include <iostream>
#include <string>
#include <stdlibh>
using namespace std;
class person {//新建人物类
public:
person();
~person();
void setname(string inputname){
name=inputname;
}
string getname(){
return name;
}
void setbmi(double bmi){
person::bmi=bmi;
}
double getbmi(){
return bmi;
}
private:
string name;//姓名
double bmi;//BMI
};
person::person(){
}
int main(){
person p1=new person();//人物对象
string text1 = "Type your first name (with no space):";
string text2 = "Type metric for metric system, type standard for standard system:";
string input;
string weight,height;
double bmi;
int choice;
bmi=00;
cout<<text1<<endl;
cin>>input;
p1->setname(input);
cout<<text2<<endl;
cin>>input;
if(input=="standard")//判断属于那种system
choice=0;
else if (input=="metric")
choice=1;
else if (input=="unknow")
choice=2;
switch(choice){
case 0:
cout<<"Type in your weight in pound and your height in inch:"<<endl;
cin>>weight>>height;
bmi=((atof((weightc_str())))/((atof(heightc_str()))(atof(heightc_str()))))703;//计算bmi
p1->setbmi(bmi);
break;
case 1:
cout<<"Type in your weight in kilogram and your height in meter:"<<endl;
cin>>weight>>height;
bmi=(atof(weightc_str()))/((atof(heightc_str()))(atof(heightc_str())));
p1->setbmi(bmi);
break;
case 2:
cout<<"Type in your weight in pound and your height in inch:"<<endl;
cin>>weight>>height;
bmi=((atof((weightc_str())))/((atof(heightc_str()))(atof(heightc_str()))))703;
p1->setbmi(bmi);
break;
}
cout<<p1->getname()<<", your BMI is "<<p1->getbmi()<<endl;
cout<<p1->getname()<<", you are considered to be ";
if(p1->getbmi()<185){//判断category
cout<<"Underweight"<<endl;
}
else if(p1->getbmi()<250){
cout<<"Normal"<<endl;
}
else if(p1->getbmi()<300){
cout<<"Overweight"<<endl;
}
else {
cout<<"Obese"<<endl;
}
}
基本上行了,你试试,至于system和category,system是关键字,不过用不上,category可以弄成一个变量,我这里没用,也没必要。
ConsleWrite("请输入体重(KG):");
double w=ConsoleRead();
ConsleWrite("请输入身高(米):");
double h=ConsoleRead();
double BMI=w/h2;
if(BMI>20&&BMI<25)
{
ConsoleWrite("正常的");
}
else
{
ConsoleWrite("异常的");
}
由于我这里没有代码环境,这是大体思路,具体编写时你要注意语法等情况
以上就是关于计算BMI的程序怎么写全部的内容,包括:计算BMI的程序怎么写、python简单题不会,求解答、C++,输入体重,身高,算bmi等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)