Requirements
"According to the weight standards recommended by the World Health Organization, men's standard weight = (height cm-80) X70﹪, women's standard weight
= (height cm-70) X60﹪. Standard body weight positive and negative 10﹪ for normal body weight, standard body weight positive and negative 10﹪~ 20﹪ for overweight or excessive
The standard body weight or positive 20﹪ above is obese or underweight, among which the overweight formula is: overweight (%) =[(actual weight-standard
Weight)/(standard weight)]x100%, weight in kg.
Please compile the program, enter a person's name, gender, height, weight, with a strong human nature of the word output of its weight (positive
Overweight, underweight, obese, or underweight), this procedure can be used to weigh the weight of people in real time on a scale.
Requires that a struct type be used to represent information about a person.
/*copyright (c) 2014, College of Computer and Control engineering, Yantai University *all rights reserved.* file name: test.cpp* Author: Lenkidong * Completion Date: December 21, 2014 * Version number: v1.0* Problem Description: " According to the weight standards recommended by the World Health Organization, men's standard weight = (height cm-80) X70﹪, women's standard weight = (height cm-70) X60﹪. The standard body weight positive and negative 10﹪ is normal body weight, the standard body weight positive and negative 10﹪~ 20﹪ is overweight or excessively light, the standard body weight and positive 20﹪ above is obese or underweight, in which the overweight formula is: overweight (%) =[(actual weight-standard weight)/(weight)]x100%, body weight in kg. Please write a program, enter a person's name, gender, height, weight, with a strong human voice to output their weight (normal, overweight, too light, fat or underweight), the program can be used in the scale for people to report the weight of the situation in real time. Requires that a struct type be used to represent information about a person. * Input Description: Two integers representing height and weight * Program output: Weight status */#include <iostream>using namespace std;struct people{string name; char sex; int high; int weight;}; int main () {double std1,std2; People *p; P=new people; cout<< "Please enter your name, gender (M, W), Height, weight! "<<endl; cin>>p->name>>p->sex>>p->high>>p->weight; std1= (p->high-80) *0.7; Std2= (p->high-70) *0.6; if (p->sex== ' m ') {if (P->WEIGHT<0.8*STD1) cout<< "Your weight is too light! "; else if (P->WEIGHT<0.9*STD1) cout<< "Your weight is too light"; else if (p->weight<1.1*stD1) cout<< "Your weight is normal"; else if (P->WEIGHT<1.2*STD1) cout<< "Your weight is too fat"; else cout<< "Your weight is too fat"; } else {if (P->WEIGHT<.8*STD2) cout<< "Your weight is too light! "; else if (P->WEIGHT<0.9*STD2) cout<< "Your weight is too light"; else if (P->WEIGHT<1.1*STD2) cout<< "Your weight is normal"; else if (P->WEIGHT<1.2*STD2) cout<< "Your weight is too fat"; else cout<< "Your weight is too fat"; } return 0;}
Operation Result:
Learning experience:
Good study Day Day up
17th Week Item 3-Fat man can't afford to hurt