I don't get any errors when compiling, but when i run the program, it just gets stuck in the do-while loop(from lines 64-69) that deals with the person's gender. no matter what I enter for the person's gender, it just asks for it again. Do you see what it might be?
Thanks!
*/
#include <stdio.h>
#include <math.h>
int main()
{
double pounds=0, kg=0, height=0, bmi=0, meter=0, dBMI=0, tKG=0, weight=0, IBW=0;
char gender=0, m=0, f=0;
// Read in weight of person in pounds
do
{
printf("Enter the weight of the person in pounds (between 90 and 350).\n");
scanf("%lf", £s);
}
while( pounds <= 90.0 || pounds >= 350.0);
// Read in the height of person in inches
do
{
printf("Enter the height of the person in inches (between 59 and 78).\n");
scanf("%lf", &height);
}
while (height <= 59.0 || height >= 78.0);
kg=pounds/2.2046;
meter=height*.0254;
bmi = kg/(meter*meter);
printf("The BMI is: %.2lf.", bmi);
// Read in the desired BMI
do
{
printf("\n\nEnter the desired BMI (between 18.5 and 30).\n");
scanf("%lf", &dBMI);
}
while (dBMI <=18.5 || dBMI >=30);
tKG = dBMI*(meter*meter);
weight = tKG*2.2046;
printf("The target weight is: %.2lf.\n", weight);
//Read in the person's gender
do
{
printf("\nIs the person a male or female? Enter m or f:\n");
scanf(" %c", &gender);
}
while (gender != m || gender != f);
//Compute IBW according to gender
if (gender == m)
{
IBW = 50.0 + 2.3 * (meter - 60.0);
printf("The ideal weight is: %lf.", IBW);
}
else if (gender == f)
{
IBW = 45.5 + 2.3 * (meter - 60.0);
printf("The ideal weight is: %lf.", IBW);
}
return 0;
}
This post has been edited by JackOfAllTrades: 11 February 2010 - 06:19 AM

New Topic/Question
Reply




MultiQuote





|