17th Week Item 3-Fat man can't afford to hurt

Source: Internet
Author: User

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-&GT;WEIGHT&LT;0.8*STD1) cout<< "Your weight is too light!        ";        else if (P-&GT;WEIGHT&LT;0.9*STD1) cout<< "Your weight is too light"; else if (p->weight<1.1*stD1) cout<< "Your weight is normal";        else if (P-&GT;WEIGHT&LT;1.2*STD1) cout<< "Your weight is too fat";    else cout<< "Your weight is too fat"; } else {if (P-&GT;WEIGHT&LT;.8*STD2) cout<< "Your weight is too light!        ";        else if (P-&GT;WEIGHT&LT;0.9*STD2) cout<< "Your weight is too light";        else if (P-&GT;WEIGHT&LT;1.1*STD2) cout<< "Your weight is normal";        else if (P-&GT;WEIGHT&LT;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.