我有一个 do while 循环要求用户输入。在这个 do while 循环中,我有一个 switch 语句。我怎样才能做到这一点,如果满足默认值重复循环再次询问用户性别?
do
{
cout << "What is your weight?" << endl;
cin >> weight;
cout << "What is your height?" << endl;
cin >> height;
cout << "What is your age?" << endl;
cin >> age;
cout << "What is your gender?" << endl;
cin >> gender;
switch (gender)
{
case 'M':
case 'm':
cout << endl << Male(weight, height, age);
break;
case 'F':
case 'f':
cout << endl << Female(weight, height, age);
break;
default:
cout << "What is your gender?";
}
cout << "Do you want to continue? (Y/N)" << endl;
cin >> stopApp;
} while(toupper(stopApp) == 'Y');