Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: The use of computers in education is referred to as computer-assisted i

ID: 641968 • Letter: P

Question

Problem: The use of computers in education is referred to as computer-assisted instruction (CAI). In this exercise, you will write a program that will help an elementary school student learn addition, subtraction, multiplication and division. Allow the user to pick a type of arithmetic problem to study: 1 addition problems only 2 subtraction problems only 3 multiplication problems only 4 division problems only 5 random mixture of all types The program should then prompt the user with a question, such as: How much is 6 times 7? The student inputs the answer. The program checks the student

Explanation / Answer

#include <iostream>

#include <cmath>

#include <cstdlib>

using namespace std;

/*

This is a program that assists elementary school students in learning

addition, subtraction, multiplication, and division.

The user chooses his or her grade level and the type of problems to be studied,

and the program begins.

Variable Dictionary:

Integers:

    right : The number of questions answered correctly by the user.

            Used to determine percentage of correct answers.

    wrong : The number of questions answered incorrectly by the user.

    leftoperand, rightoperand : The random numbers generated to form an arithmetic operation.

    response : The random text response chosen for a students correct or incorrect answer.

    answer : The correct answer to the randomly chosen arithmetic operation.

    studentanswer : The answer the student inputs to the randomly chosen arithmetic operation.

    grade : Input from the user that determines the number of

            digits that will be used in the arithmetic operations.

Characters:

    category : Determines which type of arithmetic operations will be used. Chosen by user.

*/

int main ()

{

int right=0,wrong=0;    /* Declaring and setting number of questions answered either

                                     incorrectly or correctly to 0. */

int leftoperand, rightoperand, response, answer, studentanswer, grade;

char category;

cout<<"Please choose an arithmetic problem category:"<<endl;

cout<<"A for addition, S for subtraction, M for multiplication, or D for division"<<endl;

cin>>category; // getting operand category from user

cout<<"Now choose your grade level: 1 for single-digit numbers, 2 for two-digit numbers, etc."<<endl;

cin>>grade; // getting grade level from user

for(int i=0; i<10; i++) // for loop used to limit number of questions to 10.

{

leftoperand = (pow(10, grade - 1)) + rand()%((pow(10,grade))-1);

// generate a random number with as many digits as the user chose based on grade level

rightoperand = (pow(10, grade - 1)) + rand()%((pow(10,grade))-1);

// same, for right side of arithmetic operation

if (category == 'A' || category == 'a') // addition problems category section

{

answer = leftoperand + rightoperand;

cout<<"How much is "<<leftoperand<<" + "<<rightoperand<<"?"<<endl; // asking student arithmetic question

cin>>studentanswer;

    if (studentanswer==answer) // determining if student answered question correctly

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    right++; // increasing number of correct answers

case 0:

    cout<< "Excellent!"<<endl;

    break;

case 1:

    cout<< "Very Good!"<endl;

    break;

case 2:

    cout<< "Nice Work!"<<endl;

    break;

default:

    cout<< "Keep up the good work!"<<endl;

    break;

}           // switch

}           // nested if

else (studentanswer!=answer)

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    wrong++; // increasing number of incorrect answers

case 0:

    cout<< "No. Please try again."<<endl;

case 1:

    cout<< "Wrong. Try once more."<<endl;

case 2:

    cout<< "Don't give up!"<<endl;

default:

    cout<< "No. Keep trying."<<endl;

}           // switch

}           // nested else

}           // ending if category == addition section

else if (category == 'S' || category == 's')

{

answer = leftoperand - rightoperand;

cout<<"How much is "<<leftoperand<<" - "<<rightoperand<<"?"<<endl; // asking student arithmetic question

cin>>studentanswer;

    if (studentanswer==answer)

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    right++; // increasing number of correct answers

case 0:

    cout<< "Excellent!"<<endl;

    break;

case 1:

    cout<< "Very Good!"<endl;

    break;

case 2:

    cout<< "Nice Work!"<<endl;

    break;

default:

    cout<< "Keep up the good work!"<<endl;

    break;

}           // switch

}           // nested if

else (studentanswer!=answer)

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    wrong++; // increasing number of incorrect answers

case 0:

    cout<< "No. Please try again."<<endl;

case 1:

    cout<< "Wrong. Try once more."<<endl;

case 2:

    cout<< "Don't give up!"<<endl;

default:

    cout<< "No. Keep trying."<<endl;

}           // switch

}           // nested else

}           // ending if category == subtraction section

else if (category == 'M' || category == 'm')

{

answer = leftoperand * rightoperand;

cout<<"How much is "<<leftoperand<<" * "<<rightoperand<<"?"<<endl; // asking student arithmetic question

cin>>studentanswer;

    if (studentanswer==answer)

    {

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    right++; // increasing number of correct answers

case 0:

    cout<< "Excellent!"<<endl;

    break;

case 1:

    cout<< "Very Good!"<endl;

    break;

case 2:

    cout<< "Nice Work!"<<endl;

    break;

default:

    cout<< "Keep up the good work!"<<endl;

    break;

}           // switch

}           // nested if

else (studentanswer!=answer)

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    wrong++; // increasing number of incorrect answers

case 0:

    cout<< "No. Please try again."<<endl;

case 1:

    cout<< "Wrong. Try once more."<<endl;

case 2:

    cout<< "Don't give up!"<<endl;

default:

    cout<< "No. Keep trying."<<endl;

}           // switch

}           // nested else

}           // ending if category == multiplication section

else if (category == 'D' || category == 'd')

{

answer = leftoperand / rightoperand;

cout<<"How much is "<<leftoperand<<" / "<<rightoperand<<"?"<<endl; // asking student arithmetic question

cin>>studentanswer;

    if (studentanswer==answer)

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    right++; // increasing number of correct answers

case 0:

    cout<< "Excellent!"<<endl;

    break;

case 1:

    cout<< "Very Good!"<endl;

    break;

case 2:

    cout<< "Nice Work!"<<endl;

    break;

default:

    cout<< "Keep up the good work!"<<endl;

    break;

}           // switch

}           // nested if

else (studentanswer!=answer)

{

response = rand() %3; // random number generator for computer response to student's answer

switch (response)

{

    wrong++; // increasing number of incorrect answers

case 0:

    cout<< "No. Please try again."<<endl;

case 1:

    cout<< "Wrong. Try once more."<<endl;

case 2:

    cout<< "Don't give up!"<<endl;

default:

    cout<< "No. Keep trying."<<endl;

}           // switch

}           // nested else

}           // ending if category == division section

else // If the user entered invalid character

{

i--; // decreasing the number of questions by 1 because a question is not actually asked.

cout<< "Error!"<<endl;

}

} // for loop

cout<<"You answered "<<right<<"questions correctly, and "<<wrong<<"questions incorrectly."<<endl;

cout<<"This gives you a score of "<<(right/10)*100<<"out of 100"<<endl;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote