help displaying iterations after loop goes through

Hello,

I was wondering if someone could help me with a way to display a counter on my output after each loop is ran. My program is to convert phone number phrases into full numerical numbers (800-mattress = 800-628-8737).
part of the assignment is to display the counter on the output after each loop runs through. What the assignment is asking for is something like :
800-mattress
800-628-8737
conversion 1
800-ghostly
800-446-7859
conversion2
etc....

thanks in advanced for any help


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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <iostream>
using namespace std;

int main() {
	int Counter;
	int AreaCode;
	char PhonePhrase{};
	char Choice;
	char Again{};

	do
	{
		cout << " Would you like to convert a phone number? ";
		cout << "Press Y/y for yes or N/n for no and to end program: " << endl;
		cin >> Choice;
		cout << endl << endl;
		if (Choice !='Y'&&Choice!='y'&&Choice != 'N'&&Choice !='n')
		{
			cout << " Invalid choice! Enter either Y/y or N/n" << endl;
			cout << "Press Y/y for yes or N/n for no and to end program: " << endl;
			cin >> Choice;
		}
		
		  if(Choice == 'Y' || Choice == 'y')
		{
			cout << "Enter a Phone Phrase: Area code and Phrase seperated by a '-' " << endl;
			cout << endl << endl;
			cin >> AreaCode;
			cout << "\t" << "\t" << "\t" << "\t" << AreaCode;
			for (Counter = 0; Counter >= 0 && Counter < 8; Counter++)
			{
				cin >> PhonePhrase;
				if (Counter == 0)
					cout << "-";
				if (Counter == 4)
					cout << "-";
				if (PhonePhrase >= 'A' && PhonePhrase <= 'Z' || PhonePhrase >= 'a' && PhonePhrase <= 'z')
					switch (PhonePhrase)
					{
					case 'A':
					case 'a':
					case 'B':
					case 'b':
					case 'C':
					case 'c':
						cout << "2";
						break;
					case 'D':
					case 'd':
					case 'E':
					case 'e':
					case 'F':
					case 'f':
						cout << "3";
						break;
					case 'G':
					case 'g':
					case 'H':
					case 'h':
					case 'I':
					case 'i':
						cout << "4";
						break;
					case 'J':
					case 'j':
					case 'K':
					case 'k':
					case 'L':
					case 'l':
						cout << "5";
						break;
					case 'M':
					case 'm':
					case 'N':
					case 'n':
					case 'O':
					case 'o':
						cout << "6";
						break;
					case 'P':
					case 'p':
					case 'Q':
					case 'q':
					case 'R':
					case 'r':
					case 'S':
					case 's':
						cout << "7";
						break;
					case 'T':
					case 't':
					case 'U':
					case 'u':
					case 'V':
					case 'v':
						cout << "8";
						break;
					case 'W':
					case 'w':
					case 'X':
					case 'x':
					case 'Y':
					case 'y':
					case 'Z':
					case 'z':
						cout << "9";
						
						break;
						system("Pause");
						cout << endl << endl;
					}
			}
			cout << endl << endl;
			cout << "##############################################################################" << endl;
			cout << endl << endl;
			cout << " do you want to convert again?";
			cin >> Again;

		}
		

	} while (Again == 'Y' || Again == 'y');
	
	return 0;
}
  Put the code you need help with here.
1
2
3
4
5
6
int iteration = 1;
do{
   //...
   std::cout << "Iteration number " << iteration << '\n';
   ++iteration;
}while (condition);
Last edited on
thanks for your response. another question. do you know a way to have input and output display on the same line?

something like
800- mattress 800-628-8737

right now it is displaying like this
800-mattres
800-mattress.
i would like to get them to be on the same line in the output window. thanks
Topic archived. No new replies allowed.