-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuggy1.cpp
More file actions
52 lines (37 loc) · 978 Bytes
/
buggy1.cpp
File metadata and controls
52 lines (37 loc) · 978 Bytes
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
#include <iostream>
#include <string>
using namespace std;
string trackUserAnswer();
int main()
{
string courseNamesTable[5];
string courseName;
string userAnswer;
int courseCounter = 0;
do
{
cout << "Enter a course name:\n";
getline(cin,courseName,'\n');
courseNamesTable[courseCounter] = courseName;
cout << "You are registered for the following " << courseCounter + 1 << " courses:\n";
for (int i=0; i<=courseCounter; i++)
{
cout << i+1 << ". " << courseNamesTable[i] << "\n";
}
userAnswer = trackUserAnswer();
courseCounter++;
} while(userAnswer.compare("y") == 0);
return 0;
}
string trackUserAnswer()
{
string userAnswer;
while (userAnswer.compare("n") && userAnswer.compare("y"))
{
cout << "\n Do you Want to register for another course? (y/n)\n";
cin >> userAnswer;
cin.ignore(1000, '\n');
cout << "Your Answer is:" << userAnswer << "\n";
}
return userAnswer;
}