i need to 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.
im not sure how to do the classes, some help would be great!!
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
|
#include<iostream>
#include<cstdlib>
#include<string>
#include<conio.h>
using namespace std;
const int MAX_QUESTIONS=20;
class Question //question class
{
int questionMarks;
string possibleAns;
int chosenAnswer;
string question;
public:
Question();
void setQuestion(string q);
int (string); //declare method
void setQuestion();
void show();
private:
};
class Quiz //quiz class
{
string questions;
public:
Quiz();
void run();
void questions();
Question questions[MAX_QUESTIONS];
private:
int number_of_questions;
};
void Question::setQuestion(string q)
{
question=q;
}
void Question::show()
{
cout<< question << endl;
}
void Quiz::run()
{
for(int i=0;i<number_of_questions;i++)
{
cout<<"Question" << i+1 << endl;
questions[i].show();
}
}
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;
q.questions[0].setQuestion("What colour is");
q.run();
_getch();
return 0;
}//main
|