Write a C++ documented program to perform the role of a quiz maker. The program
ID: 3716438 • Letter: W
Question
Write a C++ documented program to perform the role of a quiz maker. The program should randomly display True/False questions, record student's answers, keep track of the timing, and calculate the final score out of 10.
The program should work as follows:
Prompt the student to enter their First name and Last name (both of type string), and ID (a number of 6 digits)
Validate the entered ID, if the length of ID is not 6 digits, stay at step 2 and prompt the user to re-enter the correct ID. After 3 failed attempts, exit the program. If the student entered a valid name and ID go to step 3.
Randomly pick ten questions with their answers form the Q and A arrays.
Display one question at a time. Get the answer, then move to the next question.
Do not accept answers other than true or false (T or F should be fine too). The answers should not be case sensitive.
When the user is done with the quiz, print out a report (On screen) with the below information in it: First name and Last name Score Elapsed time Student’s answers and the correct answer.
Prompt the student to enter Q to exit the program, or to enter S to clear the screen and start a new quiz for another student.
Requirements
The program skeleton will include two string arrays Q for questions and A for answers, that you will use to pick the quiz questions from.
In each quiz, your program should display ten unique random questions (no repeated questions).
Users have 10 minutes to complete the quiz, after 10 minutes the program should automatically terminate the quiz, and report the outputs to the screen. All questions have the same weight. 10 questions for 10 points.
Code optimization (breaking your code into functions):
Modify your code to include the following functions:
bool Validate_ID (int ID): to validate the length of the ID, if 6 returns true otherwise returns false.
bool Unique_Question (int questionNumber): to check if the question already was used before in the quiz or not, if the question was used before returns false, otherwise returns true.
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
bool Unique_Question (int questionNumber){
}
bool Validate_ID (int id){
//if ID is good return false to continue
if(id%100000== id ){
return true;
}else{
return false;}
}
int main ()
{
string A[100]={"TRUE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"FALSE",
"FALSE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"FALSE",
"TRUE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"TRUE",
"FALSE",
"TRUE",
"TRUE",
"FALSE",
"FALSE",
"TRUE",
"TRUE",
"FALSE",
"FALSE"};
// Gather user information, first name, last name, id.
string name1;
string name2;
string id;
int counter = 0;
srand(time(0));
cout<<"Please enter your First Name and your Last Name" << endl;
cin>>name1;
cin>>name2;
cout<<endl;
do{
if(counter == 3 ){
exit(0);
}
cout<<”Please enter your ID” << endl;
cin >> id;
counter = counter +1;
}while(Validate_ID(id));
// prompt to begin the quiz
int question_number =0 , int score = 0;
string response;
string answer1 = "yes";
cout<<"Instructions: Answer all 10 true or false questions in lower case letters."<<endl<<endl;
cout<<"Are your ready to take the quiz? "<<name1<<” “<<name2<<"? "<<endl;
cout<<"Input yes to begin."<<endl;
cin>>response;
cout<<endl;
if(response== anser1)
cout<<"Have fun!";
cout<<endl;
cout<<endl;
// add the 10 minute timer
//ask for x being 10 or 20
//get x
time_t start, now, finish;
Start = time(0);
For(int i =0 ; i < x; ++i){
Loop here to
question_number = Rand() % 100;
HERE call upon Unique_Question(question_number); to test if you used that number or not
cout << Q_Array[question_number] << endl;
cin >> response;
now = time(0);
if (difftime(now, start) >= 600){
exit(0);
}
if(response == A_Array[question_number]){
score = score +1;
}
}
finish= time(0);
// Present the score and test results
cout << “Test Results for " << name1 << ” “ << name2 << endl;
cout << “Score: “ << << “0%” endl;
cout << “Submitted answers and correct answers:” << endl;
cout << “time elapsed: “ << difftime(finish,start) << endl;
cout << “1. Correct Answer: true. Your answer: “ << responce2 << endl;
cout << “2. Correct Answer: true. Your answer: “ << responce3 << endl;
cout << “3. Correct Answer: true. Your answer: “ << responce4 << endl;
cout << “4. Correct Answer: false. Your answer: “ << responce5 << endl;
cout << “5. Correct Answer: false. Your answer: “ << responce6 << endl;
cout << “6. Correct Answer: true. Your answer: “ << responce7 << endl;
cout << “7. Correct Answer: true. Your answer: “ << responce8 << endl;
cout << “8. Correct Answer: false. Your answer: “ << responce9 << endl;
cout << “9. Correct Answer: true. Your answer: “ << responce10 << endl;
cout << “10. Correct Answer: false. Your answer: “ << responce11 << endl;
system("PAUSE");
return 0;
}
Here is my codeThe bold is what i need help on. please basic programming c++
Explanation / Answer
#include /* random record description - could be anything */ struct rec { int x,y,z; }; /* writes and then reads 10 arbitrary records from the file "junk". */ int main() { int i,j; FILE *f; struct rec r; /* create the file of 10 records */ f=fopen("junk","w"); if (!f) return 1; for (i=1;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.