Write a program that keeps prompting the user to input weight in pounds and heig
ID: 3669734 • Letter: W
Question
Write a program that keeps prompting the user to input weight in pounds and height in inches, and then calculates and prints the body mass index (BMI) and health message based on the BMI.
Formula for BMI
The program must have the following 3 methods: 1) A method that reads a number from keyboard Input to the method: None Output of the method: double variable 2) A method that calculates the BMI Input to the method: two double variables (pounds, inches) Output of the method: double variable (BMI) 3) A method that prints the results Input to the method: three variables (pounds, inches, BMI) Output of the method: none (void method)
Explanation / Answer
#include <stdio.h>
#define FEETTOMETER 0.3048
int main() {
float weight, height, bmi;
/* get the input weight from the user */
printf("Enter your weight(in kgs):");
scanf("%f", &weight);
/* get the input height from the user */
printf("Enter your height(in feet):");
scanf("%f", &height);
/* height in meters */
height = height * FEETTOMETER;
/* bmi calculation */
bmi = (weight)/(height * height);
/* print the result */
printf("Your Body Mass Index: %f ", bmi);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.