プロジェクトの方向性は次のように述べています。
「活動レベルについては、入力が有効でない場合は、メッセージを出力して、ユーザーが座っていると想定していることをユーザーに伝えてください。」</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
とうまくいきますが、現時点で設定している方法で必要な結果が得られるかどうか疑問に思っています。