Grammar Quiz Game
Grammar Quiz Game
In CT 215 PROGRAMMING
Submitted by:
JUN AL ESPAÑOL
Submitted to:
June 3,2023
Project Description:
The purpose of this project is to develop a quiz game program (Grammar quiz)
that allows users to test their knowledge on a specific topic. The scope of the project
includes designing and implementing a user-friendly interface, creating a database of
questions and answers, and implementing the logic for presenting questions, accepting
user responses, and providing feedback on the correctness of the answers.
1. User Interaction: Develop an intuitive and user-friendly interface that allows users to
navigate through the quiz, submit their answers, and receive feedback on their
performance.
4. Answer Evaluation: Develop the logic to evaluate user responses and provide
immediate feedback on the correctness of the answers. The program should accurately
assess whether the provided answer matches the expected answer and display the
appropriate result to the user.
5. Scoring and Progress Tracking: Implement a scoring system that assigns points for
correct answers and keeps track of the user's progress throughout the quiz. Display the
final score at the end of the quiz, allowing users to gauge their performance and
improve their knowledge.
6. Code Maintainability: Ensure that the code is well-structured, modular, and adheres
to good programming practices. Utilize functions to enhance code readability and
maintainability, making it easier to debug, modify, and extend the program in the future.
By achieving these objectives, the project aims to provide an engaging and educational
quiz experience for users, allowing them to test their knowledge, learn new information,
and track their progress over time.
System requirements:
Hardware Requirements:
Software Requirements:
2. C++ Compiler: You will need a C++ compiler to compile and run the code. Popular
options include GCC (GNU Compiler Collection), Clang, and Microsoft Visual C++
Compiler.
3. Integrated Development Environment (IDE): While not mandatory, using an IDE can
provide a more convenient development environment. Examples of C++ IDEs include
Visual Studio, Code::Blocks, and Eclipse CDT.
4. Standard Template Library (STL): The C++ code may rely on the Standard Template
Library (STL) for various data structures and algorithms. The STL is typically included
with the C++ compiler.
Flow diagrams:
Algorithms:
#include <iostream>
#include <string>
void welcomeMessage() {
cout << "Test your grammar knowledge by answering a series of questions." << endl;
cout << "Each question has multiple choices, and you need to enter the
corresponding letter (a, b, or c) for your answer." << endl;
int main() {
welcomeMessage();
string easyQuestions[] = {
"2. Choose the correct form of the verb: He ___ to school every day.",
"3. Select the pronoun that best completes the sentence: ___ like to eat pizza.",
"4. Identify the preposition in the sentence: The book is ___ the table.",
"7. Select the correct word order for a basic English sentence:",
"8. Identify the adverb in the sentence: She ran quickly to catch the bus.",
"9. Choose the correct form of the verb: They ___ playing soccer in the park.",
"10. Select the conjunction in the sentence: I like both ice cream ___ cake."
};
string easyChoices[] = {
};
string easyCorrectAnswers[] = {
"a",
"c",
"c",
"b",
"c",
"a",
"a",
"b",
"c",
"a"
};
string mediumQuestions[] = {
"1. Choose the correct form of the verb: She ___ to the party last night.",
"2. Identify the direct object in the sentence: They bought ___ new car.",
"4. Identify the pronoun in the sentence: ___ will be there in a moment.",
"5. Choose the correct form of the verb: He ___ his bike to work every day.",
"7. Identify the adverbial phrase in the sentence: She sings with joy.",
"8. Choose the correct form of the possessive pronoun: That book is ___",
"9. Identify the conjunction in the sentence: I like to swim and play tennis.",
"10. Choose the correct form of the verb: They ___ their vacation in Europe."
};
string mediumChoices[] = {
};
string mediumCorrectAnswers[] = {
"a",
"c",
"c",
"b",
"a",
"b",
"a",
"b",
"a",
"c"
};
string hardQuestions[] = {
"1. Choose the correct form of the verb: She ___ already ___ her homework before
dinner.",
"3. Select the correct form of the adjective: This is the ___ book I have ever read.",
"4. Identify the relative pronoun in the sentence: The person ___ won the
competition will get a prize.",
"5. Choose the correct form of the verb: They ___ studying for hours when I
arrived.",
"6. Select the correct word order for a passive sentence in English:",
"7. Identify the infinitive phrase in the sentence: He wants to learn how to play the
guitar.",
"8. Choose the correct form of the pronoun: The gift is for ___",
"9. Identify the participial phrase in the sentence: The dog, wagging its tail, greeted
me at the door.",
"10. Choose the correct form of the verb: She ___ her best to win the competition."
};
string hardChoices[] = {
"a) has, done\nb) have, did\nc) had, do\n",
"a) Object - Verb - Subject\nb) Verb - Subject - Object\nc) Subject - Verb - Object\
n",
"a) to learn how to play the guitar\nb) wants to learn how\nc) how to play the guitar\
n",
};
string hardCorrectAnswers[] = {
"c",
"a",
"a",
"a",
"b",
"b",
"a",
"a",
"a",
"b"
};
// Difficulty levels
enum Difficulty {
EASY,
MEDIUM,
HARD
};
Difficulty level;
char levelChoice;
while (true) {
case 'E':
case 'e':
level = EASY;
break;
case 'M':
case 'm':
level = MEDIUM;
break;
case 'H':
case 'h':
level = HARD;
break;
default:
cout << "Invalid choice. PLEASE TRY ENTER VALID CHOICE" << endl;
continue;
break;
string *questions;
string *choices;
string *correctAnswers;
int numQuestions;
switch (level) {
case EASY:
questions = easyQuestions;
choices = easyChoices;
correctAnswers = easyCorrectAnswers;
break;
case MEDIUM:
questions = mediumQuestions;
choices = mediumChoices;
correctAnswers = mediumCorrectAnswers;
break;
case HARD:
questions = hardQuestions;
choices = hardChoices;
correctAnswers = hardCorrectAnswers;
break;
}
// Quiz loop
int score = 0;
string userAnswer;
cout << "Enter your answer (a, b, or c), or 'q' to exit: ";
userAnswer = tolower(userAnswer[0]);
if (userAnswer == "q") {
if (userAnswer == correctAnswers[i]) {
score++;
} else {
cout << "The correct answer is " << correctAnswers[i] << endl;
if (!exitQuiz) {
cout << "Your score: " << score << "/" << numQuestions << endl;
} else {
cout << "Quiz exited. Your progress will not be recorded." << endl;
return 0;
}
Testing:
Conclusion:
We conclude that the grammar quiz project was successfully implemented using
C++. The program allowed users to test their grammar knowledge by answering a
series of questions with multiple-choice options. The project aimed to provide an
interactive and educational experience for users to improve their grammar skills.
Throughout the development process, several challenges were encountered.
One of the challenges was designing the user interface to be intuitive and user-
friendly. This involved presenting the questions, choices, and feedback in a clear and
organized manner. Additionally, validating user input and handling different scenarios,
such as allowing users to quit the quiz, posed implementation challenges.