Commit c5f44b00 authored by Karine's avatar Karine

exercise_06_36, version5

parent 5d777a47
......@@ -5,12 +5,10 @@
#include <ctime>
std::string
printAnswer(const bool answerStatus)
printCorrectAnswer()
{
const int answerType = 1 + std::rand() % 4;
std::string response;
if (answerStatus) {
switch(answerType) {
case 1: response = "Very good!"; break;
case 2: response = "Excellent!"; break;
......@@ -18,7 +16,16 @@ printAnswer(const bool answerStatus)
case 4: response = "Keep up the good work!"; break;
default: response = "Good job"; break;
}
} else {
return response;
}
std::string
printIncorrectAnswer()
{
const int answerType = 1 + std::rand() % 4;
std::string response;
switch(answerType) {
case 1: response = "Please try again."; break;
case 2: response = "Wrong.Try once more."; break;
......@@ -27,11 +34,9 @@ printAnswer(const bool answerStatus)
default: response = "Nooooo"; break;
}
}
return response;
}
}
int
main()
......@@ -61,7 +66,12 @@ main()
}
answerStatus = (first * second == answer);
std::cout << printAnswer(answerStatus) << std::endl;
if (answerStatus) {
std::cout << printCorrectAnswer() << std::endl;
} else {
std::cout << printIncorrectAnswer() << std::endl;
}
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment