Question: The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible. Also if

The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible. Also if possible please provide comment lines as I can learn more about the subject.

The following instructions for this program:

The following program is not allowed to use global variables!

Implement a function named getUserInfo to get user's name, gender, and age.

Implement a function named printMenu to print the menu options to users.

Implement a function name getUserChoice to get user's choice and validate user's choice. If the user's choice input is not a valid option of the menu, tell the users that the option input is invalid and repeatedly ask for another input until a choice is valid.

Implement Option 1 as a function (e.g. named input).

Implement Option 2 as a function (e.g. named print).

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

The following is what should happen when the program is ran:

Once the program starts, first, ask the users to input their name, gender, and age by calling getUserInfo function.

Then print a text menu with the following options to present the choices for users by calling printMenu function and ask users to choose one option by calling getUserChoice function.

Option 1: Input: This option is to input today's weight and exercise information including exercise type and time.

Option 2: Input: This option is to print user's latest inputs including user's name, gender, age, weight, exercise type and time.

If users haven't selected option 1 before print, then show a message "no fitness data to print".

Option 3: Exit: This option is to exit the program (only this option will stop the program.)

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

The following code is what I have, please use this a base and keep it simple, no need for advance codes. This is all done in Visual Studio 2022 C++

#include #include #include using namespace std;

int main() {

string name, gender, exercise; int age, option; double weight, time;

//Getting user's information cout << "Enter your name: " << endl; getline(cin, name);

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

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

while(!(stringstream(age_input) >> age)) {

cout << "Invalid input. Please enter a numeric value for your age: " << endl; getline(cin, age_input);

}

cout << "Enter your weight(kg): " << endl; string weight_input; getline(cin, weight_input);

while (!(stringstream(weight_input) >> weight)) {

cout << "Invalid input. Please enter a numeric value for your weight(kg): " << endl; getline(cin, weight_input);

}

//Showing the menu options do {

cout << " Select an Option from the menu below: "; cout << "Option 1: Input today's weight and exercise information. "; cout << "Option 2: Print user's latest inputs. "; cout << "Option 3: Exit the program. ";

string option_input; getline(cin, option_input); stringstream(option_input) >> option;

//Performing the selected option switch (option) {

case 1: cout << endl << "Today's Information: " << endl; cout << "Weight(kg): " << weight << "kg" << endl; cout << "Exercise: " << exercise << " (" << time << "minutes)" << endl; cout << "Enter type of exercise: " << endl; getline(cin, exercise); cout << "Enter length of exercise(minutes): " << endl; string time_input; getline(cin, time_input); while (!(stringstream(time_input) >> time)) {

cout << "Invalid input. Please enter a numeric value for the exercise time: " << endl; getline(cin, time_input);

} break;

case 2: cout << endl << "User's Information: " << endl; cout << name << " (" << gender << "," << age << ")" << endl; cout << "Weight(kg): " << weight << "kg" << endl; cout << "Exercise: " << exercise << " (" << time << "minutes)" << endl; break;

case 3: cout << "Exiting the program. GOODBYE!" << endl; break;

default: cout << "Invalid Option. Please select a valid option." << endl; break;

}

} while (option != 3);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!