该项目的方向如下:
“对于活动级别,如果输入无效,则打印一条消息并告诉用户您假设他们是久坐的。”</p>
以下是我当前的代码,我正在尝试将其设置为"Sedentary"
用户可以输入为 SA 或 sa 的默认值。无效输入的默认设置应该使程序默认为久坐,我有点困惑我是否在正确的轨道上。
else if (gender == 'F' || gender == 'f') {
cout << "Please enter your Height in inches. (You may include a decimal) ";
cin >> height;
cout << "Please enter your Weight in pounds as a whole number. ";
cin >> weight;
cout << "Please enter your Age in years. ";
cin >> age;
cout << endl;
if (activity_level = 'SA' || activity_level = 'sa' || activity_level = 'LA' || activity_level = 'la' ||
activity_level = 'MA' || activity_level = 'ma' || activity_level = 'VA' || activity_level = 'va') {
cout << "Please enter your activity level." << endl << endl;
cout << "You may enter one of the following choices." << endl << endl;
cout << "Sedentary (Little or no exercise) \"SA\" or \"sa\" " << endl;
cout << "Lightly Active (Light exercise/sports 1-3 days a week) \"LA\" or \"la\" " << endl;
cout << "Moderately Active (Moderate exercise/sports 3-5 days a week) \"MA\" or \"ma\" " << endl;
cout << "Very Active (Hard exercise/sports 6-7 days a week) \"VA\" or \"va\" " << endl << endl;
cout << "Enter your activity level now. ";
cin >> activity_level;
cout << endl;
}
// Output for the message to defualt to Sedentary if you do not select activity level throught he proper input.
else {
activity_level =
cout << "I'm sorry I did not recogonize that activity level. We will assume a sedentary amount of exercise. "
}
}
基本上我想知道,如果我在做什么;在语句中使用另一个 if 语句else if
将起作用,我想知道我目前设置它的方式是否会产生所需的结果。