Loop with a Y/N (continue/end)

I need to write a program that will ask for a # associated with a day of the week. once they select I need a a Y/N to continue with another try or exit the program. I'm just stuck. I'm sure the do loop with the extra while loop is not needed but I can not get this to work. Any help would be great. I feel I'm close and just need a nudge in the right direction.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

	int numb, choice;
	
	cout << "Enter a number for a day of the week (Sun = 1, Sat = 7): ";
	cin >> numb;

	while (numb < 1 || numb > 7)
	{
		cout << numb << " is invalid" << endl;
		cout << "Enter a number for a day of the week (Sun = 1, Sat = 7): ";
		cin >> numb;
	}
	
		if (numb == 1)
			cout << "Sunday" << endl;
		else if (numb == 2)
			cout << "Monday" << endl;
		else if (numb == 3)
			cout << "Tuesday" << endl;
		else if (numb == 4)
			cout << "Wednesday" << endl;
		else if (numb == 5)
			cout << "Thursday" << endl;
		else if (numb == 6)
			cout << "Friday" << endl;
		else if (numb == 7)
			cout << "Saturday" << endl;

		do
		{
			cout << "Do you wish to continue? ";
			cin >> choice;

			while (choice == 'y' || choice == 'n')
			{
				cout << "Do you wish to continue? ";
				cin >> choice;
			}
			
			if (choice == 'y')
			cout << "Enter a number for a day of the week (Sun = 1, Sat = 7): ";
			cin >> numb;
			
			while (numb < 1 || numb > 7)
			{
				cout << numb << " is invalid" << endl;
				cout << "Enter a number for a day of the week (Sun = 1, Sat = 7): ";
				cin >> numb;
			}

			if (numb == 1)
				cout << "Sunday" << endl;
			else if (numb == 2)
				cout << "Monday" << endl;
			else if (numb == 3)
				cout << "Tuesday" << endl;
			else if (numb == 4)
				cout << "Wednesday" << endl;
			else if (numb == 5)
				cout << "Thursday" << endl;
			else if (numb == 6)
				cout << "Friday" << endl;
			else if (numb == 7)
				cout << "Saturday" << endl;

			cout << "Do you wish to continue? ";
			cin >> choice;
		}
		 while (choice != 'n');

		
		cout << "Goodbye!  Thank you for using our program!" << endl;

	return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;

int main()
{
	const char *days[7] = {"Sunday", "Moday", "Tuesday", "Wednesday",
	                       "Thursday", "Friday", "Saturday"};
	int numb, choice;
	
	do
	{
		cout << "Enter a number for a day of the week (Sun = 1, Sat = 7): ";
		cin >> numb;

		while (numb < 1 || numb > 7)
		{
			cout << numb << " is invalid\n";
			cout << "Enter a number for a day of the week (Sun = 1, Sat = 7): ";
			cin >> numb;
		}

		cout << days[numb - 1] << '\n';

		cout << "Do you wish to continue? ";
		cin >> choice;

		while (choice == 'y' || choice == 'n')
		{
			cout << "Do you wish to continue? ";
			cin >> choice;
		}
	}
	while (choice == 'y');

	cout << "Goodbye!  Thank you for using our program!\n";

	return 0;
}

Thank you for the quick response. Hopefully soon my code will start looking that neat and
that compact! There is still the issue with if the user selects "y" (after asking "do you wish to continue") it needs loops back around and start over. only "n" should exit out and give "Goodbye" message. This still ends the program no matter what is chosen.
I figured it out.. "choice" needed to be a char not an int. A few broken keys later and all is good. Thanks again for the help.
Topic archived. No new replies allowed.