วันอังคารที่ 23 กันยายน พ.ศ. 2551

2.ให้เขียนโปรแกรม สำหรับคำนวณน้ำหนักมาตรฐาน โดยให้ป้อนข้อมูล ส่วนสูง น้ำหนัก เพศ[M , F] (Filename : weight.cpp)
#include
#include
void main()
{
char fm;
float h,w;
clrscr();
printf("Your Male(m) or Female(f) : ");scanf("%c",&fm);
printf("\nYour Weight : ");scanf("%f",&w);
printf("\nYour Hight : ");scanf("%f",&h);
switch(fm)
{
case 'm': if(h-100==w)printf("\nYou Standardweight ");
else if(h-100)printf("\nYour weight > Standard : %0.2fkg",w-(h-100));
else if(h-100>w)printf("\nYour weight Less Than Standard : %0.2fkg",(h-110)-w);break;
case 'f': if(h-110==w)printf("\nYou Standard weight ");
else if(h-110printf("\nYour weight > Standard : %0.2fkg",w-(h-110));
else if(h-110>w)printf("\nYour weight less Than Standard : %0.2fkg",(h-110)-w);break;
getch();
}

ไม่มีความคิดเห็น: