设计一个健康评估软件,作为公益项目。
根据一个人的身高,体重,运动能力,肺活量等外在的指标,对一个人的健康状况进行量化评估。80分以上为健康,60分以上健康状况一般,60分以下为不健康。
具体评分细则:
男同胞
体重指数(体重(kg)/身高(m)2):(25%)
17-23: 100分
23-28:80分
小于17:70分
28以上:60分
肺活量:(35%)
小于3000:30分
3000-4000:60分
4000-4800:80分
4800以上:100分
引体向上:(40%)
20以上:100分
15-20:80分
10-15:60分
10以下:30分
女同胞
体重指数(体重(kg)/身高(m)2):(25%)
17-23: 100分
23-28:80分
小于17:70分
28以上:60分
肺活量:(35%)
小于2000:30分
2000-3000:60分
3000-3500:80分
3500以上:100分
仰卧起坐:(40%)
60以上:100分
50-60:80分
25-50:60分
25以下:30分
这是我用xcode写的,还请多指教
#include "stdio.h"
int Male_test(int wei,int hei,int pul,int up)
{
int ratio;
int s1,s2,s3,s4;
ratio=wei/hei;
if (ratio>=17||ratio<23) s1=25;
if (ratio>=23||ratio<=28) s1=20;
if (ratio<17) s1=17.5;
if (ratio>28) s1=15;
if (pul<3000) s2=10.5;
if (pul>=3000||pul<4000) s2=21;
if (pul>=4000||pul<=4800) s2=27;
if (pul>4800) s2=35;
if (up>20) s3=40;
if (up<10) s3=12;
if (up>=10||up<15) s3=24;
if (up>=15||up<=20) s3=32;
s4=s1+s2+s3;
return s4;
}
int Female_test(int wei,int hei,int pul,int up)
{
int ratio;
int s1,s2,s3,s4;
ratio=wei/hei;
if (ratio>=17||ratio<23) s1=25;
if (ratio>=23||ratio<=28) s1=20;
if (ratio<17) s1=17.5;
if (ratio>28) s1=15;
if (pul<2000) s2=10.5;
if (pul>=2000||pul<3000) s2=21;
if (pul>=3000||pul<=3500) s2=27;
if (pul>3500) s2=35;
if (up>60) s3=40;
if (up<25) s3=12;
if (up>=25||up<50) s3=24;
if (up>=50||up<=60) s3=32;
s4=s1+s2+s3;
return s4;
}
int main()
{
int height,weight;
int pulmonary;
int pull_up,sit_up,result;
int gender;
printf("Please choose your gender:\n[1]Male\n[2]Female\n");
scanf("%d",&gender);
switch (gender) {
case 1:
printf("Please the male's weight,height,pulmonary and pull_up\n");
scanf("%d%d%d%d",&weight,&height,&pulmonary,&pull_up);
result=Male_test(weight, height, pulmonary, pull_up);
if (result<60) printf("Unhealth\n");
if (result>80) printf("Health\n");
else printf("Common\n");
break;
case 2:
printf("Please the female's weight,height,pulmonary and sit_up\n");
scanf("%d%d%d%d",&weight,&height,&pulmonary,&sit_up);
result=Male_test(weight, height, pulmonary, sit_up);
if (result<60) printf("Unhealth\n");
if (result>80) printf("Health\n");
else printf("Common\n");
break;
}
return 0;
}