Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   c++ multiple choice quiz (http://www.go4expert.com/forums/cpp-multiple-choice-quiz-t27054/)

kueen 31Oct2011 21:34

c++ multiple choice quiz
Create a C++ program to run a simple multiple choice quiz on C++. The quiz should have questions such as this:
Question 1
How do you declare a variable x to be a pointer to a constant integer?
1) int * const x
2) int const * const x
3) int const *x
4) int *x
Select answer (1-4) :>

The program should have two classes called Question and Quiz.
The Question class should hold all the data and methods for a single question with four different possible answers.
It should include fields to hold:
1) The question;
2) The possible answers;
3) The marks for each answer;
4) A comment to give to a user for each choice of answer;
5) The answer selected by the user.
It should have methods to:
1) Display the question;
2) Obtain an answer from the user;
3) Return the userís score;
4) Display the comments.
The Quiz class should hold an array of up to 20 questions. It should have methods to:
1) Present the questions in order;
2) Display the total score;
3) Take the user through their answers showing the correct answer and the comment.
Both classes may have other fields, methods or constructors as appropriate.
You should have a main method that sets up a quiz with 4 questions, runs the quiz and displays the scores and comments.
I have no idea how to create these classes!please help!!

//COM316 Coursework 2 2011
usingnamespace std;
constint MAX_QUESTIONS=20;
class Question //question class
int questionMarks;
string possibleAns;
int chosenAnswer;
string question;
void setQuestion(string q);
int (string); //declare method
void setQuestion();
void show();
class Quiz //quiz class
string questions;
void run();
void questions();
Question questions[MAX_QUESTIONS];

int number_of_questions;
void Question::setQuestion(string q)

void Question::show()
cout<< question << endl;
void Quiz::run()
for(int i=0;i<number_of_questions;i++)
"Question" << i+1 << endl;
int Quiz::Question(string s) //question method

//holds information for questions
return 0;
string Quiz::questions(string s)
//quiz method
return 0;
//array of questions
int main () //main method
Quiz q;
"What colour is");
return 0;

All times are GMT +5.5. The time now is 00:29.