Answer to Question #63846 in C++ for Nii-Odai Charles

Question #63846
2. Write a program that displays the recommended weight in kilograms, given the user’s age and height in centimeters. The formula for calculating the recommended weight is
Recommended weight = (height – 100 + age %10) *0.90
Define a service class named height and include an appropriate method for getting a recommended weight of a designated height.
1
Expert's answer
2016-12-06T10:33:10-0500
#include<iostream>
using namespace std;

class Height {
private:
int age;
double height;
double recomWeigth;
public:
Height(int age, double height){
this->age = age;
this->height = height;
}
double getWeigth() {
this->recomWeigth = (height - 100 + age % 10) * 0.90;
return recomWeigth;
}
};

int main() {
int age;
double height;
cout << "Enter age: ";
cin >> age;
cout << "Enter height: ";
cin >> height;
Height a(age, height);
cout << "Recommended weigth: " << a.getWeigth() << endl;
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS