So for this homework assignment I have to ask 3 questions and output whether their correct or not. The part i need help with is writing this code using a void function and not having all 3 questions in a single function. In other words I have to write one generic function and call it 3 times in main. So if anyone could help that would be fantastic! Thank you!
#include <iostream>
#include <string>
void query(std::string question, std::string answer) {
//print the question
//accept user input
//if the user input matches the answer, print "Correct"
//otherwise, print "Incorrect"
}
int main() {
query("Question1", "Answer1");
query("Question2", "Answer2");
query("Question3", "Answer3");
return 0;
}
The instructions you've provided also state the following:
In case of multiple correct answers, use multiple
parameters and or-logic. For example, “who founded Microsoft”, accept “Bill Gates” or “Gates”.
It sounds to me like it's not required to have questions that have multiple answers, in other words, it's up to you. For simplicity's sake, I would just choose questions that are straight forward and can't be interpreted in more than one way.
Additionally, the instructions don't mention anything about handling upper- or lower-case answers, though it might be neat for you to implement that as well.