Develop a C++ program that teaches elementary school students multiplication. Us
ID: 3621678 • Letter: D
Question
Develop a C++ program that teaches elementary school students multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as:How much is 9 times 3?
The student then types the answer. Your program checks the answer; if it is correct, the correctMessage function is called; if it is incorrect, the incorrectMessage function is called. Your program will count the number of correct and incorrect answers. After 10 answers (any/all answers count), the program will calculate the percentage of correct responses. If the percentage is lower than 75%, your program will call the needHelp function, then terminate. Otherwise, the program continues until the student enters the sentinel value (-1) to end the program.
Explanation / Answer
please rate - thanks
#include <iostream>
#include <cstdlib>
using namespace std;
void correctMessage();
void incorrectMessage();
void needHelp();
int main()
{int a,b,ans,correct,incorrect,i,more=0,score;
srand(time(0));
do{correct=0;
incorrect=0;
for(i=0;i<10;i++)
{a=rand()%10;
b=rand()%10;
cout<<"How much is "<<a<<" times "<<b<<"? ";
cin>>ans;
if(ans==a*b)
{correctMessage();
correct++;
}
else
{incorrectMessage();
incorrect++;
}
}
score=(int)(correct/10.*100.);
cout<<"you scored "<<score<<"% ";
if(score<75)
needHelp();
cout<<"again? type -1 to stop 0 to continue ";
cin>>more;
}while (more!=-1);
return 0;
}
void correctMessage()
{cout<<"correct :) ";
}
void incorrectMessage()
{cout<<"sorry:( that's wrong ";
}
void needHelp()
{cout<<"explanation ";
cout<<"How to do ";
cout<<"multiplication ";
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.