Question
need help with c++ code. Can't figure out why it's not working, please explain. See comments for details. Should call functions in the class to
need help with c++ code. Can't figure out why it's not working, please explain. See comments for details. Should call functions in the class to set variables than call function to get variables than print out BMI results.
#include
#include
class secretType {
public:
double height;
void print();//outputs the data in the member variables in a nice format
void setName();//sets the name
void setAge();//sets the age
void setWeight();//sets the weight
void setHeight();//sets the height
string getName()const;//value returning function retuns the name
int getAge()const;//value returning function returns the age
double getHeight()const;//value returning function returns the height
int getWeight()const;//value returning function returns the weight
string weightStatus();/*value returning function that returns a string
* according to the following BMI = (weight * 703/height) */
private:
string name;
int age, weight;
double height;
};
using namespace std;
int main() {
secretType start;
start.setName();
start.setAge();
start.setWeight();
start.setHeight();
start.print();
start.getName();
start.getAge();
start.getHeight();
start.getWeight();
start.weightStatus();
return 0;
}
void secretType::setName(){
cout << "Enter name: ";
cin >> name;
}
void secretType::print() {
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
cout << "Weight: " << weight << endl;
}
void secretType::setAge() {
cout << "Enter age: ";
cin >> age;
}
void secretType::setWeight() {
cout << "Enter Weight: ";
cin >> weight;
}
void secretType::setHeight() {
cout << "Enter height: ";
cin >> height;
}
string secretType::getName() {
return name;
}
int secretType::getAge() {
return age;
}
double secretType::getHeight() {
return height;
}
int secretType::getWeight() {
return weight;
}
string secretType::weightStatus() {
cout << "BMI = " << ((weight * 703) / height);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started