Question

deal weight in kilograms Male and is height Robinson formula to the following: or f male and the F calculate body male female for for performs 60) that as follow: (code) Female: (height a 1.9 1.7 program 52 49 height inches for in Marks): Write weights m and to (6 the weight in kilograms. gender M or m or wro a program that prompts the user to enter the kilograms.If the user enters a eet and then and prints the weight in invalid genderl Sample inpu sale and F or f for female: m Enter the gender M or m for 5 Enter the height in feet and inches 5 is 61.5 The ideal weight for a 65 inches male nter the gender M or m for male and F or f for female: F Enter the height in feet and inches 5 5 57.5 e ideal weight for a 65 inches female is


0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Program is given below and it is written in c++

#include <iostream>

using namespace std;

int main()
{
   char gender;
   int feet,inch,height;
   float weight;
   //prompt and accept gender from user
   cout<<"Enter the gender M or m for male and F or f for female:";
   cin>>gender;
   //if gender input from user is wrong print Invalid user and terminate
   if(gender!='M'&& gender!='m' && gender!='F' && gender!='f')
   {
        cout<<"Invalid gender!";
        return 0;
   }
   //prompt and accept height from user
   cout<<"Enter the height in feet and inches:";
   cin>>feet>>inch;

   height=feet*12+inch; //convert height in inches

   //calculate ideal weight for male and print
   if(gender=='M'||gender=='m')
   {
   weight=52+1.9*(height-60);
   cout<<"The ideal weight for a "<<height<<" inches male is "<<weight;
   }

   //calculate ideal weight for female and print
   if(gender=='F'||gender=='f')
   {
   weight=49+1.7*(height-60);
   cout<<"The ideal weight for a "<<height<<" inches female is "<<weight;
   }

   return 0;
}

/* Output

1st run:                                                                                                                                                           

Enter the gender M or m for male and F or f for female:m                                                                                                                 

Enter the height in feet and inches:5 5                                                                                                                                  

The ideal weight for a 65 inches male is 61.5                                                                                                 

2nd run:                                                                                                                                                         

Enter the gender M or m for male and F or f for female:F                                                                                                                 

Enter the height in feet and inches:5 5                                                                                                                                  

The ideal weight for a 65 inches female is 57.5                                                                                              

3rd run:                                                                                                                                                         

Enter the gender M or m for male and F or f for female:N                                                                                                                 

Invalid gender!                                                                                                                                              

Add a comment
Know the answer?
Add Answer to:
Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (JAVA) Project 2: Predicting A Child's Height (10 pts). One way to estimate the adult height...

    (JAVA) Project 2: Predicting A Child's Height (10 pts). One way to estimate the adult height of a child is to use the following appropriate formula: Hmale_child = ((Hmother * 13/12) + Hfather)/2 Hfemale_child = ((Hfather * 12/13) + Hmother)/2 Note that all heights in these formulas are in inches, so use int variables to store them Write a program that prompts for the gender of the child, the height of the father, and the height of the mother, then...

  • Write a Java program that performs these operations Prompt the user to enter a low height...

    Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...

  • Write a C program that reads the height and weight of a person and calculates the...

    Write a C program that reads the height and weight of a person and calculates the body mass index (bmi) according to formula bmi = weight/(height)2. Your program should display a qualitative assessment of the weight according to the following table: BMI value Letter Grade [0-20) Below normal weight [20-25) Normal weight [25-30) Overweight >=30 Obese Sample Output: Enter your weight in kilos: 70 Enter your height in meters: 1.80 Result: Normal weight Test values: (70 1.8) (50, 1.9) (90,...

  • Write a single C++ program that performs the following conversion (The modulus divide will help you...

    Write a single C++ program that performs the following conversion (The modulus divide will help you get the remainder as shown in class) 39 / 12 = 3 and 39 % 12 = 3, so 3 feet 3 inch(es) Height conversion 1 meter = 39 inches 12 inches = 1 foot Ask/Prompt the user to enter in the height in meters, convert and output the result in feet and inches Example 1 meters as input should produce 3 feet (foot)...

  • /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...

    /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates the user's body-mass-index (BMI) // 3. and then prints an appropriate message based on the user's BMI /////////////////////////////////////////////////////////////////////////////////// #include <iostream> using namespace std; void printWelcome(); // ask the weight (in pounds) and height (in inches) of the user and store the values in formal // parameters weight and height, respectively void getWeightAndHeight(float& weight, float& height); // calculate and return the BMI (Body-Mass-Index) based on...

  • Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input...

    Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input is ‘M’ or 'm', Female if the gender is ‘F’ or 'f', and invalid gender otherwise. 1) Declare variable, 2) draw your flow chart on the back, and 3) do the coding in C++.

  • In a group of N students (male and female), write pseudocode to compute the percentage of...

    In a group of N students (male and female), write pseudocode to compute the percentage of female that pass or fail the course. The passing score is 60 or greater. Hint: a variable, say G (as in gender) should store one of two possibilities, ‘M’ (as in ‘male’) or ‘F’ (as in ‘female’), inputted by the user.

  • You want to write a converter program which will let user convert distance and weight from SI to ...

    Use functions to complete this C + + program You want to write a converter program which will let user convert distance and weight from SI to the USCS system and vice versa The formulae are as follows: 1. Distance in miles- distance in kilometers x 1.60 2. Weight in kilograms weight in pounds x 2.20 The program would let user input the number that they want to convert and then choose the units to and from which they want...

  • IN PYTHON ONLY!!! Program 2: Design (Pseudocode) and implement (Source Code) a program that asks the...

    IN PYTHON ONLY!!! Program 2: Design (Pseudocode) and implement (Source Code) a program that asks the user for their height (in inches), weight (in pounds), age and gender. Use loops to validate user input and to continue running for a new user until a sentinel value is entered. Ask them to select their approximate level of exercise each week from the options below, then determine and print their allowed daily caloric intake using their BMR: Female BMR = 655+(4.35 *...

  • The body mass index (BMI) is a measure of relative weight based on height and weight....

    The body mass index (BMI) is a measure of relative weight based on height and weight. The body fat percentage (BFP) of a human or other living being is the total mass of fat divided by total body mass, multiplied by 100; body fat includes essential body fat and storage body fat. Essential body fat is necessary to maintain life and reproductive functions. Write a program that calculates and prints the BFP for multiple persons; the program allows user to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT