Commit efde9628 authored by Karine's avatar Karine

exercise_06_37, finally

parent 404c7c3c
......@@ -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()
......@@ -63,18 +68,21 @@ main()
}
answerStatus = (first * second == answer);
if (!answerStatus) {
if (answerStatus) {
std::cout << printCorrectAnswer() << std::endl;
} else {
std::cout << printIncorrectAnswer() << std::endl;
--incorrectAnswerCount;
}
std::cout << printAnswer(answerStatus) << std::endl;
--count;
}
}
const int result = incorrectAnswerCount * 10;
if (result < 75) {
std::cout << "Please ask your instructor for extra help." << std::endl;
return 1;
return 0;
}
std::cout << "Good job!!!" << std::endl;
......
......@@ -8,4 +8,6 @@ Don't give up.
No.Keep trying.
No.Keep trying.
Don't give up.
Please try again.
Don't give up.
Please ask your instructor for extra help.
......@@ -8,4 +8,5 @@ Wrong.Try once more.
Wrong.Try once more.
Nice work!
No.Keep trying.
No.Keep trying.
Please ask your instructor for extra help.
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