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. The following
The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible.
The following instructions for this program:
1). Once the program starts, first, ask users to input their name, gender, and age. These values stay the same during the life of the program since the application is for tracking short term fitness goals.
2). Then print a text menu with the following options to present the choices for the users and ask them to choose one option. Using the case/switch method.
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 as Project 2.
Option 3: Input. This option is to exit the program (Only this option will stop the program.)
If the user's input is none of the options in the text menu, show a message to tell users that the option input is invalid.
If the option is a valid one, the program performs the required option.
After performing one option (except for Option 3), the program needs to show the text menu repeatedly to allow users for more choices. The only way to exit the program is to choose option3.
==========================================================================
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++. Remember to use switch/case method for this program.
#include
int main() {
string name; cout << "Enter your name: " << endl; getline(cin, name);
string gender; cout << "Enter your gender: " << endl; getline(cin, gender);
int age; 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);
}
double weight; 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 you weight(kg): " << endl; getline(cin, weight_input);
}
string exercise; cout << "Enter type of exercise: " << endl; getline(cin, exercise);
double time; cout << "Enter length of exercise (mintues): " << 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);
}
cout << endl << "User Information: " << endl; cout << name << " (" << gender << ", " << age << ")" << endl; cout << "Weight: " << weight << " kg" << endl; cout << "Exercise: " << exercise << " (" << time << " mintues)" << endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
