In: Computer Science
The use of computers in education is referred to as computer-assisted instruction (CAI). More sophisticated CAI systems monitor the student’s performance over a period of time. The decision to begin a new topic is often based on the student’s success with previous topics. Modify the c++ program which I included to count the number of correct and incorrect responses typed by the student. After the student types 5 answers, your program should calculate the percentage of correct responses. If the percentage is lower than 75 percent, your program should print “Please ask for extra help” and then terminate. If the percentage is 75 percent or higher, your program should print “Good work!” and then terminate.
#include<bits/stdc++.h> //headerfile
using namespace std;
int main(){
int cont=0;
while(cont<5){ //we will come out of loop when we get 5 correct
answers
// This program will create different sequence of
// random numbers on every program run because of srand
srand(time(0));
int x=rand()%10; //we took modulo 10 because all numbers should be
between 0 to 9
int y=rand()%10;
cout<<"How much is
"<<x<<"*"<<y<<"?"<<endl;
int out;
int res=x*y;//actual output
cin>>out; //we enter the result as output
if(res==out){ //if actual output matches our solution
cout<<"Very good!"<<endl;
cont++;
}else{ //if actual output doesn't match our solution
while(res!=out){ //we will repeatedly ask the user same question
till we get answer
cout<<"No. Please try again."<<endl;
cout<<"How much is
"<<x<<"*"<<y<<"?"<<endl;
cin>>out;
}
cont++;
}
}
}
#include<bits/stdc++.h> //headerfile
using namespace std;
int main(){
int cont=0;
int incorrect = 0,correct = 0; // to count correct and
incorrect
while(cont<5){ //we will come out of loop when we
get 5 correct answers
// This program will create
different sequence of
// random numbers on every program
run because of srand
srand(time(0));
int x=rand()%10; //we took modulo
10 because all numbers should be between 0 to 9
int y=rand()%10;
cout<<"How much is
"<<x<<"*"<<y<<"?"<<endl;
int out;
int res=x*y;//actual output
cin>>out; //we enter the
result as output
if(res==out){ //if actual output
matches our solution
cout<<"correct"<<endl;;
correct++;
}else{
cout<<"wrong"<<endl;
incorrect++;
}
cont++;
}
double percent =
((double)correct/(correct+incorrect))*100; // check correct %
if(percent>=75){
cout <<"Good work!";
}else{
cout<<"Please ask for extra
help";
}
}
/* OUTPUT */
/* PLEASE UPVOTE */