60 435
Assignments Done
98,1%
Successfully Done
In April 2018

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions