Nested loop statement

I am confused of how to set up the loop here, the user will input a m for married or a s for single. If the user inputs anything else I want to redo this step. I have set it up in a way I think may work, but I am sure that it is not correct. Thanks for the help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	do
	{
		cout << "\nPlease enter an \"m\" if married and filing joint return,";
		cout << "\nor \"s\" if filing a single return: " << endl;
		getline(cin, returnType);
		if (returnType == "m")
		{
			if (returnType == "s")
			{

			}
		}
		else
		{
			cout << "that is an invalid character" << endl;
		}

	} while (returnType == false);
It's not correct: line 8 cannot be true because line 6 says so.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bool is_again = false; // Note
	do
	{
		cout << "\nPlease enter an \"m\" if married and filing joint return,";
		cout << "\nor \"s\" if filing a single return: " << endl;
		getline(cin, returnType);
		if (returnType == "m")
		{
		}
		else
			if (returnType == "s") // Note
			{

			}
		else
		{
			is_again = true; // Note
			cout << "that is an invalid character" << endl;
		}

	} while (is_again); // Note 
Thanks for the quick reply coder777.
wait I forgot something:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
bool is_again; // Note
	do
	{
		is_again = false; // Important! Otherwise is_again will never be false again
		cout << "\nPlease enter an \"m\" if married and filing joint return,";
		cout << "\nor \"s\" if filing a single return: " << endl;
		getline(cin, returnType);
		if (returnType == "m")
		{
		}
		else
			if (returnType == "s") // Note
			{

			}
		else
		{
			is_again = true; // Note
			cout << "that is an invalid character" << endl;
		}

	} while (is_again); // Note  
Topic archived. No new replies allowed.