Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that will estimate a child height based on the height of the pa

ID: 672876 • Letter: C

Question

Create a program that will estimate a child height based on the height of the parents.

The formulas (below) are based on gender.

Ask the user to enter a String representing the gender, so m or M for a male and f or F for a female. Your program must handle both upper or lower case gender enteries.

Ask the user for the height of both parents in two parts

Ask for Feet and store in an int variable.

Next ask for inches and store int variable.

So for example if the father is 6' 2'', the user would enter 6 when asked for feet and 2 when asked for inches.

Convert the height of the each parent to inches. hint 12" in one foot.

Apply the following formulas based on gender (must use an if statement(s)):

Hmale_child = ((Hmother * 13/12) + Hfather)/2

Hfemale_child = ((Hfather * 13/12) + Hmother)/2

Display in a nicely formated message the estimated height of the child , where height is displayed in feet and inches. Example The estimated child height is 5' 7"

Explanation / Answer

//Here is the Code

#include <stdio.h>

// Main Function() called by operating system

int main()
{

// variables Declaration
    char gender;             // variable for storing gender entered by user.
    int Ffeet,Mfeet;          // variable for storing Father and Mother height in Feets entered by user.
    int Finches,Minches; // variable for storing Father and Mother height in inches entered by user.
    printf("Enter Gender");
    scanf("%c",&gender);
    printf("Enter height of father(Feets Part)");
/* Please note here aFter in every scanf statement I used space before '%' like (scanf(" %d",)) because when u enter gender and press enter scanf will take new line character. So to get rid from this I used space in                format specifer in scanf */

scanf(" %d",&Ffeet);
    printf("Enter height of father(Inches Part)");
            scanf(" %d",&Finches);
    printf("Enter height of mother(feets Part)");
            scanf(" %d",&Mfeet);
    printf("Enter height of mother(Inches Part)");
            scanf(" %d",&Minches);

// Conversion of height in inches. 1 foot= 12 inches. So if user enter x foot y inches then height = x*12+y inches.
    int Hfather=Ffeet*12+Finches;
    int Hmother=Mfeet*12+Minches;

// Logic to deceide on the basis of gender entered by user.
    if(gender=='M'||gender=='m')
    {
        int Hmale_child=((Hmother * 13/12) + Hfather)/2;
        printf("The estimated child height is ");

//now height of child calculated in inches So we need to convert it again into Feets and inches. So logic is

suppose answer comes is X inches.

now 12 inches=1 foot

        1 inches = 1/12 feets

       x inches= (1/12 )* X feets. = X/12 feets

and reminder left over are inches.

So if X=64 inches then feets= 64/12= 5 feets and reminder =4 inches. So answer would be 5'4''.

printf("%d%c%d%c",Hmale_child/12,''',Hmale_child%12,'"');
      
    }
    if(gender=='F'||gender=='f')
    {
int Hfemale_child = ((Hfather * 13/12) + Hmother)/2 ;
        printf("The estimated child height is ");

        printf("%d%c%d%c",Hfemale_child/12,''',Hfemale_child%12,'"');

    }      


    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote