homework - create trivia game

I have a homework assignment to create a trivia game with classes
below is my header file, accessor/mutator file, and main file
When i run the program, it doesn't loop through the program but post the results and closes. I'm guessing it's something easy but i just need a second set of eyes

header:
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
#include <string>
#include <iostream>
using namespace std;

class question
{
private:
	string ques;
	string answer1;
	string answer2;
	string answer3;
	string answer4;
	int correctnum;
public:
void setQues(string ques);
void setAnswer1(string a1);
void setAnswer2(string a2);
void setAnswer3(string a3);
void setAnswer4(string a4);
void setCorrect(int correct);
string getQues() const;
string getAnswer1() const;
string getAnswer2() const;
string getAnswer3() const;
string getAnswer4() const;
int getCorrect() const;
};



accessors/mutators:
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
/*
accessors and mutators for the question class
*/
#include "stdafx.h"
#include <iostream>
#include "question.h"
using namespace std;

//mutators
void question::setQues(string q)
{
	ques = q;
}
	
void question::setAnswer1(string a1)
{
	answer1 = a1;
}
	
void question::setAnswer2(string a2)
{
	answer1 = a2;
}

void question::setAnswer3(string a3)
{
	answer1 = a3;
}
	
void question::setAnswer4(string a4)
{
	answer1 = a4;
}

void question::setCorrect(int correct)
{
	correctnum = correct;
}
	
//accessors
string question::getQues() const
{ 
	return ques;
}
	
string question::getAnswer1() const
{ 
	return answer1;
}
	
string question::getAnswer2() const
{ 
	return answer2;
}
	
string question::getAnswer3() const
{ 
	return answer3;
}

string question::getAnswer4() const
{ 
	return answer4;
}

int question::getCorrect() const
{
	return correctnum;
};



main:
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
127
128
129
130
131
132
133
134
135
136
/*
	create a simple trivia game for two players. the program should start with player one each player gets a turn at answering 5 trivia questions (10 total)
	when a question is displayed, four possible answer are displayed, only one answer is the correct answer. correct answer earns a point
	after answers have been selected for all questions the program will display the number of points earned by each player and declare the winner
*/
#include "stdafx.h"
#include "question.h"
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

void questionAns(question[], int);
int main() {//start main
	question trivia[10]; //10 instances of Game class
	int count = 0; //used to count through loop and as index
	//variables to hold players answers
	int onechoice; 
	int twochoice;
	//holds total points for each player
	int onePoints = 0;
	int twoPoints = 0;
	int x;
	cout << "Let's test your math knowledge." << endl;
	cout << "May the best person win" << endl;
	//creating questions and answer in each object
    // QUESTION ONE   
	trivia[0].setQues("What is the sum of two plus two?");
		trivia[0].setAnswer1("1.  six");
		trivia[0].setAnswer2("2.  three");
		trivia[0].setAnswer3("3.  eight");
		trivia[0].setAnswer4("4.  four");
		trivia[0].setCorrect(4);
		// QUESTION TWO  
	trivia[1].setQues("What is the product of thirty divided by five?");
		trivia[1].setAnswer1("1.  two");
		trivia[1].setAnswer2("2.  six");
		trivia[1].setAnswer3("3.  ten");
		trivia[1].setAnswer4("4.  seven");
		trivia[1].setCorrect(2);
		// QUESTION THREE  
	trivia[2].setQues("What is the product of eighteen divided by nine minus one?");
		trivia[2].setAnswer1("1.  one");
		trivia[2].setAnswer2("2.  seven");
		trivia[2].setAnswer3("3.  six");
		trivia[2].setAnswer4("4.  three");
		trivia[2].setCorrect(1);
		// QUESTION FOUR   
	trivia[3].setQues("If you drive eighty miles and consume four gallons of gas, how many miles per gallon did you achieve?");
		trivia[3].setAnswer1("1.  thirteen");
		trivia[3].setAnswer2("2.  forty");
		trivia[3].setAnswer3("3.  twenty");
		trivia[3].setAnswer4("4.  eighty");
		trivia[3].setCorrect(3);
		// QUESTION FIVE  
	trivia[4].setQues("If you drive a constant sixty miles per hour how many miles will you cover in three hours?");
		trivia[4].setAnswer1("1.  eighteen");
		trivia[4].setAnswer2("2.  one hundred and twenty");
		trivia[4].setAnswer3("3.  one hundred and eighty");
		trivia[4].setAnswer4("4.  none of the above");
		trivia[4].setCorrect(3);
		// QUESTION SIX   
	trivia[5].setQues("You have to be to work at seven thirty every morning, It normally takes you twenty minutes to drive to work. What time should you leave?");
		trivia[5].setAnswer1("1.  Seven ten");
		trivia[5].setAnswer2("2.  six o'clock");
		trivia[5].setAnswer3("3.  six thirty");
		trivia[5].setAnswer4("4.  none of the above");
		trivia[5].setCorrect(1);
		// QUESTION SEVEN   
	trivia[6].setQues("There is a road construction causing a ten minute detour. What time should you leave?");
		trivia[6].setAnswer1("1.  six thirty");
		trivia[6].setAnswer2("2.  seven o'clock");
		trivia[6].setAnswer3("3.  eight o'clock");
		trivia[6].setAnswer4("4.  seven o'clock");
		trivia[6].setCorrect(2);
		// QUESTION EIGHT   
	trivia[7].setQues("If your vehicle has a 20 gallon gas tank and gas costs 3.79 per gallon. how much would it cost to fill 5 gallons");
		trivia[7].setAnswer1("1.  seventy five dollars and eighty cents");
		trivia[7].setAnswer2("2.  it's free");
		trivia[7].setAnswer3("3.  eighteen dollars and ninty-five cents");
		trivia[7].setAnswer4("4.  three dollars and seventy-nine cents");
		trivia[7].setCorrect(3);
		// QUESTION NINE   
	trivia[8].setQues("What is pi");
		trivia[8].setAnswer1("1.  3.14159");
		trivia[8].setAnswer2("2.  food");
		trivia[8].setAnswer3("3.  3.15149");
		trivia[8].setAnswer4("4.  2");
		trivia[8].setCorrect(1);
		// QUESTION TEN   
	trivia[9].setQues("What is the reduced mixed number for one point eight zero");
		trivia[9].setAnswer1("1.  three fourths");
		trivia[9].setAnswer2("2.  two and one thirds");
		trivia[9].setAnswer3("3.  one and three fourths");
		trivia[9].setAnswer4("4.  four thirds");
		trivia[9].setCorrect(3);
	while(count < 9, count++) {//start while   loop for actual game
		
		cout << setw(10) << " QUESTION " << (count + 1) << endl;
		
		questionAns(trivia,count); 
		cout << "Player 1's answer: ";
		cin >> onechoice;
		cout << "Player 2's answer: ";
		cin >> twochoice;

		//if statements check to see if answers are right, if they are right then they get a point 
		if(trivia[count].getCorrect() == onechoice) { 
			onePoints++;
		}
		if(trivia[count].getCorrect() == twochoice) {
			twoPoints++;
		}
		cout << endl << endl;
	}

	if ( onePoints == twoPoints) {
		cout << "Both players were tied." << endl;
	}
	if ( onePoints > twoPoints) {
		cout << "Player one wins!" << endl;
	}else {
		cout << "Plaer two wins!" << endl;
	}
	cout << "Thanks for playing, press any key to exit.";
	cin >> x;
}

void questionAns(question z[], int count) 
{
	cout << z[count].getQues() << endl;
	cout << z[count].getAnswer1() << endl;
	cout << z[count].getAnswer2() << endl;
	cout << z[count].getAnswer3() << endl;
	cout << z[count].getAnswer4() << endl;
}
I don't see and for loops in this program
Thank you
Topic archived. No new replies allowed.