Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible. The program needs to

This is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible.

The program needs to ask users to provide:

User's name (string value, can be multiple words)

User's gender (string value)

User's age (integer value)

User's weight today (real value, unit: kg)

User's exercise type today (string value, can be multiple words) and the exercise time (real value, unit: minute)

Need to ensure the inputs of age, weight, and exercise time are of numeric values. E.g., if users give an age input as 'sixty', the program needs to inform users that it's a bad input and ask for another input until the input is valid.

Print the user's information to the console as follows:

User's name (Gender, Age)

Weight: today's weight kg

Exercise: today's exercise type (time mintues)

=========================================================================================================================================

The following code is what I have, please use this a base and keep it simple. Please use while loops.

#include #include using namespace std;

int main() {

string name; cout << "Enter your name: " << endl; getline(cin, name);

string gender; cout << "Enter your gender: " << endl; getline(cin, gender);

string exercise; cout << "Enter type of exercise: " << endl; getline(cin, exercise);

int age; //cout << "Enter your age: " << endl; //cin >> age;

if (age > 0) {

cout << "Enter your age: " << endl; cin >> age;

} else {

cout << "Please enter numeric values!";

}

double weight; //cout << "Enter your weight: " << endl; //cin >> weight;

if (weight > 0) {

cout << "Enter your weight: " << endl; cin >> weight;

} else {

cout << "Please enter numeric values!";

}

double time; //cout << "Enter lenght of exercise: " << endl; //cin >> time;

if (time > 0) {

cout << "Enter lenght of exercise: " << endl; cin >> time;

} else {

cout << "Please enter numeric values!";

}

cout << name << "(" << gender << "," << age << ")" << endl; cout << "Weight: " << weight << endl; cout << "Exercise: " << exercise << "(" << time << "minutes)" << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Let a > 0. Show that the series (1 + an)-1 is divergent if 0 1.

Answered: 1 week ago

Question

6. The leader asks the observers to report their observations.

Answered: 1 week ago