Create a quiz answer sheet checker. That does the following: 1. Posts questions – at least 5- then let the user input answers per question , it can be a multiple choice question, or solving question which will have a number for an answer. 2. After the user inputs their answer, let the program check the answer and display the score of the user.
#include <iostream>
#include <string>
#include <cstdio>
#include <Windows.h>
using namespace std;
int main() {
cout << "1. The first question\n" << //write yor questions here
"2. The second question\n" <<
"3. The third question\n" <<
"4. The fourth question\n" <<
"5. The fifth question\n\n";
short int number_of_questions = 5;
short int score = 0;
string ans;
for (int i = 0; i < number_of_questions; i++) {
cout << "Enter the number of the answering question: ";
int n;
cin >> n;
switch (n) {
case 1:
cout << "Enter the answer: ";
getline(cin, ans);
getline(cin, ans);
if (ans == "answer 1") { //write yor correst answers here
cout << "Your score is: " << ++score << endl;
}
break;
case 2:
cout << "Enter the answer: ";
getline(cin, ans);
getline(cin, ans);
if (ans == "answer 2") {
cout << "Your score is: " << ++score << endl;
}
break;
case 3:
cout << "Enter the answer: ";
getline(cin, ans);
getline(cin, ans);
if (ans == "answer 3") {
cout << "Your score is: " << ++score << endl;
}
break;
case 4:
cout << "Enter the answer: ";
getline(cin, ans);
getline(cin, ans);
if (ans == "answer 4") {
cout << "Your score is: " << ++score << endl;
}
break;
case 5:
cout << "Enter the answer: ";
getline(cin, ans);
getline(cin, ans);
if (ans == "answer 5") {
cout << "Your score is: " << ++score << endl;
}
break;
default:
cout << "wrong answer" << endl;
break;
}
}
return 0;
}
Comments
Leave a comment