所以我环顾四周,但显然我要么没有找对地方,要么我误解了一些东西。
给出的指示是程序只能接受 2.0 到 5.0 之间的拱顶高度值。我觉得这与我的 if 条件有关,但我不知道如何纠正它。
当我在调试期间输入高度时,它会跳转到我的 else 语句,并且不给我机会重新输入新的输入。
//Retrieving name and first vault and date
cout << "Please enter the name of the pole vaulter.\n";
getline(cin, name);
cout << "Please enter the height of the first vault attempt.\n";
cin >> vault1;
if(5.0 >= vault1 >= 2.0) {
cout << "What date was this vault accomplished?\n";
getline(cin, date1);
} else {
cout << "Only jumps between 2.0 meters and 5.0 meters are valid inputs. Please enter the height of the first vault attempt.\n";
cin >> vault1;
cout << "What date was this vault accomplished?\n";
getline(cin, date1);
}