Thanks for your patience with me. I know these messages are probably annoying. Thanks for bearing with me.
So my new assignment is as follows:
I have read the lecture material repeatedly as well as the notes and I have done my very best with the knowledge I have so far. I have skipped the floating point part because I haven't a clue what to put. Same with the feet to inches conversion.(15 points.) According to the Center for Disease Control (CDC), Body Mass Index (BMI) is a
“reliable indicator of body fatness for most people and is used to screen for weight categories
that may lead to health problems.” An adult’s BMI is a function of his or her weight and
height, the formula for which is
w/h(square)x703
where w is weight in pounds and h is height in inches.
Adults’ weights can be categorized by
BMI per the table below.
BMI Status
< 18.5 Underweight
18.5 – 24.9 Normal
25.0 – 29.9 Overweight
> 29.9 Obese
Write, in a file called bmi.c, a program that first prompts users for their weight and height and then informs them of their BMI and status. Americans tend to think in terms of feet, so let users provide their height in feet plus inches. The aesthetics of your program are largely up to you, but your program must prompt users for input in this order: pounds then feet then inches. Functionally, then, your program must resemble the below. Underlined are some sample inputs.
Weight in pounds: 165
Height (feet): 6
Height (inches): 2
Your BMI is 21.2. You are normal.
As implied by the above, do require that users’ inputs be non-negative; rather than quit upon invalid input, let the user re-try again and again. Also round your program’s floating-point output to one decimal place.
For the record this won't compile (surprise, I know). This is what I have come up with so far:
Again, I have read everything I can get my hands on before posting this.Code:#include <stdio.h> #include <cs50.h> int main(int argc, char * argv[]) { int weight, height, inches, total; printf("Enter your weight in pounds: "); weight = GetInt(); printf("Enter your height in feet (i.e. if you are 6'4, enter 6: "); height = GetInt(); printf("Enter your height in inches (i.e. if you are 6'4, enter 4: "); inches = GetInt(); total=(weight / height * height * 703); if (total < 18.5) printf("You are underweight\n"); else if (total >= 18.5 && total <=24.9) printf("You are normal weight\n"); else if (total >= 25.0 && total <= 29.9) printf("You are overweight\n"); else (total > 29.9) printf("You are obese\n"); return 0; }
Thank you kindly for your help.
PS: I will gladly take hints too. I am not looking to cut corners. I truly want to learn C. Feel free to make me think with some good questions !