IDNStudy.com, ang iyong gabay para sa maaasahan at mabilis na mga sagot. Alamin ang mga maaasahang sagot sa iyong mga tanong mula sa aming malawak na kaalaman sa mga eksperto.

Create a program that allows the user to take exam. The exam should have 5 questions (You can ask any questions). The questions are in multiple choice form and the choices are numbers. The program will display the questions one by one, and then the user can enter the correct number that corresponds to his answer. Every time the user answers question the program will check if it is correct, if the answer is correct the program will print "Correct!" otherwise it will display "Incorrect!" and the correct answer. Once the user is done with all the questions, the program will display the score and the equivalent percentage that the user got

Sagot :

//The code below is written in C++

#include <iostream>

int getChoice(){

int a = 0;

std::cout << "Enter your choice: ";

std::cin >> a;

std::cin.ignore();

return a;

}

int main(){

int choice = 0;

int score = 0;

std::cout << "9 multiplied by 9 is ?\n";

std::cout << "(1) 64\n";

std::cout << "(2) 81\n";

std::cout << "(3) 75\n";

std::cout << "(4) 72\n";

choice = getChoice();

if(choice == 2){

std::cout << "Correct!\n";

++score;

}else{

std::cout << "Incorrect! The answer is 81\n";

}

std::cout << "16 multiplied by 9 is ?\n";

std::cout << "(1) 196\n";

std::cout << "(2) 1054\n";

std::cout << "(3) 169\n";

std::cout << "(4) 144\n";

choice = getChoice();

if(choice == 4){

std::cout << "Correct!\n";

++score;

}else{

std::cout << "Incorrect! The answer is 144\n";

}

std::cout << "17 multiplied by 24 is ?\n";

std::cout << "(1) 408\n";

std::cout << "(2) 2408\n";

std::cout << "(3) 208\n";

std::cout << "(4) 168\n";

choice = getChoice();

if(choice == 1){

std::cout << "Correct!\n";

++score;

}else{

std::cout << "Incorrect! The answer is 408\n";

}

std::cout << "12 multiplied by 7 is ?\n";

std::cout << "(1) 84\n";

std::cout << "(2) 74\n";

std::cout << "(3) 94\n";

std::cout << "(4) 14\n";

choice = getChoice();

if(choice == 1){

std::cout << "Correct!\n";

++score;

}else{

std::cout << "Incorrect! The answer is 84\n";

}

std::cout << "100 multiplied by 0 is ?\n";

std::cout << "(1) 1\n";

std::cout << "(2) 100\n";

std::cout << "(3) 0\n";

std::cout << "(4) Undefined\n";

choice = getChoice();

if(choice == 3){

std::cout << "Correct!\n";

++score;

}else{

std::cout << "Incorrect! The answer is 0\n";

}

std::cout << "Test is done!\nYou're Score: " << score << "/5 : " << (score * 100 / 5) << "%\n";

return 0;

}