Write a program code in C++ to compute the ideal weight for both males and femal
ID: 646152 • Letter: W
Question
Write a program code in C++ to compute the ideal weight for both males and females. According to one study,
the ideal weight for a female is 100 pounds plus 5 pounds for each inch in height over 5 feet. For
example, the ideal weight for a female who is 5'3" would be 100 + 3*5 = 115 pounds. For a male
the ideal weight is 106 pounds plus 6 pounds for each inch in height over 5 feet. For example,
the ideal weight for a male who is 5'3" would be 106 + 3*6 = 124 pounds. Your program should
ask the user to enter his/her height in feet and inches (both as integers
Explanation / Answer
#include <iostream>
using namespace std;
int main() {
int feet,inches;
int weight;
char gen;
cout<<"enter the gender f/m";
cin>>gen;
cout<<"enter the height feet and inches";
cin>>feet;
cin>>inches;
cout<<"gender";
cout<<gen;
if(gen=='f')
{
if(feet==5 && inches==0)
{
weight=100;
}
if (inches>0)
{
weight=inches*3+weight;
cout<<"weight";
cout<<weight;
}
if(gen=='m')
{
if(feet==5 && inches==0)
{
weight=106;
}
if (inches>0)
{
weight=inches*6+weight;
}
cout<<"weight";
cout<<weight;
}
}
cout<<"gender and weight ";
cout<<gen;
cout<<" ";
cout<<weight;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.