Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that asks for the gender and the all the input appropriate to the gender, then calculate and display the Body Fat and

Write a program that asks for the gender and the all the input appropriate to the gender, then calculate and display the Body Fat and Body Fat Percentage.

For Example:

This program determines the body fat of a person.

Enter your gender (f|F|m|M): F

Enter body weight (in pounds): 120

Enter wrist measurement at fullest point (in inches): 5

Enter waist measurement at navel (in inches): 32

Enter hip measurement at fullest point (in inches): 36

Enter forearm measurement at fullest point (in inches): 23

Body fat: 25.586643 Body fat percentage: 21.322203

--------------------------------------------

This program determines the body fat of a person.

Enter your gender (f|F|m|M): m

Enter body weight (in pounds): 120

Enter waist measurement at fullest point (in inches): 5

Body fat: -83.510000 Body fat percentage: -69.591667

Here's my code:

#include

int main() {

char gender;

int a1;

int a2;

int a3;

int a4;

int a5;

int waistmeasurement;

int wristmeasurement;

int hipmeasurement;

int forarmmeasurement;

int B;

int bodyweight;

int Bodyfat;

int Bodyfatpercentage;

printf("Enter your gender F|f|M|m");

scanf("%c", &gender);

printf(" ");

if(gender=='F' || gender=='f'){

printf("Enter your body weight(in pounds):", bodyweight);

scanf("%d ", &bodyweight);

printf("Enter wrist measurement at fullest point(in inches):", wristmeasurement);

scanf("%d ", &wristmeasurement);

printf("Enter waist measurement at navel(in inches):", waistmeasurement);

scanf("%d ", &waistmeasurement);

printf("Enter hip measurement at fullest point(in inches):", hipmeasurement);

scanf("%d ", &hipmeasurement);

printf("Enter forarm measurement at fullest point(in inches):", forarmmeasurement);

scanf("%d ", &forarmmeasurement);

a1=bodyweight * 0.732 + 8.987;

a2=wristmeasurement/3.140;

a3=waistmeasurement * 0.157;

a4=hipmeasurement * 0.249;

a5=forarmmeasurement * 0.434;

B=a1+a2+a3+a4+a5;

Bodyfat = bodyweight - B;

Bodyfatpercentage=(Bodyfat*100)/bodyweight;

printf("Body fat: ", Bodyfat);

printf(" ");

printf("Body fat percentage: ", Bodyfatpercentage);

printf(" ");

}

if(gender=='M' || gender=='m'){

printf("Enter your body weight(in pounds):", bodyweight);

scanf("%d ", &bodyweight);

printf("Enter waist measurement at navel(in inches):", waistmeasurement);

scanf("%d ", &waistmeasurement);

a1=bodyweight * 1.082 + 94.42;

a2=waistmeasurement * 4.15;

B=a1-a2;

Bodyfat = bodyweight - B;

Bodyfatpercentage=(Bodyfat*100)/bodyweight;

printf("Body fat: ", Bodyfat);

printf(" ");

printf("Body fat percentage: ", Bodyfatpercentage);

printf(" ");

}

else{

printf("Invaild Choice");

return(0);

}

return(0);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions