// the preprocessing directives
#include <iostream>
#include <iomanip> // setprecision(2) and fixed
using namespace std;
int main() {
// declare and initialize variables
int height;
float age, weight;
cout << setprecision(2) << fixed;
cout << "Age: ";
cin >> age;
cout << "Height (cm): ";
cin >> height;
if(age>0 && height>0 ){
weight = float(height-100 + int(age)%10)*0.90 ;
cout<<"Recommended weight: "<< weight<<endl;
}
else
cout << endl <<"Age and Height must be positive numbers "<<endl;
return 0;
}
Comments
Leave a comment