Here is the program in C. Let me know in the comment if you need help understanding the problem or if you face any errors.
Program
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int rightAnswers = 0;
int wrongAnswers = 0;
int getNumber(int difficultyLevel)
{
// we don't want to generate number 0. ( in case of
divisions)
// hence this check.
int number = 0;
do
{
number = rand() % (int)pow(10, difficultyLevel);
}while(number == 0);
return number;
}
int getRandomNumberBetweenRange(int start, int end)
{
return (rand() % (end - start + 1)) + start;
}
void printCorrectAnswer()
{
const static char message[][40] = {"Very good!", "Excellent!",
"Nice Work!", "Keep the good work!"};
int messageIndex = getRandomNumberBetweenRange(0,3);
printf("%s", message[messageIndex]);
rightAnswers++;
}
void printWrongAnswer()
{
const static char message[][40] = {"No. Please try again.", "Wrong.
Try once more.", "Don't give up!", "No. Keep trying"};
int messageIndex = getRandomNumberBetweenRange(0,3);
printf("%s", message[messageIndex]);
wrongAnswers++;
}
// PRE:
// questionType between 1 to 5.
// difficultyLevel between 1 to 3.
void getQuestion(int questionType, int difficultyLevel)
{
int firstNumber = getNumber(difficultyLevel);
int secondNumber = getNumber(difficultyLevel);
if(questionType == 5) questionType =
getRandomNumberBetweenRange(1,4);
char op = ' ';
do
{
switch(questionType)
{
case 1: op = '+'; break;
case 2: op = '-'; break;
case 3: op = '*'; break;
case 4: op = '/'; break;
}
printf("\nHow much is %d %c %d? ", firstNumber, op,
secondNumber);
double studentAnswer = 0, answer = 0;
scanf("%lf", &studentAnswer);
switch(questionType)
{
case 1: answer = firstNumber + secondNumber; break;
case 2: answer = firstNumber - secondNumber; break;
case 3: answer = firstNumber * secondNumber; break;
case 4: answer = (double)firstNumber / secondNumber; break;
}
if(questionType == 4)
{
if(abs(answer-studentAnswer) < 0.01)
{
printCorrectAnswer();
break;
}
else
{
printWrongAnswer();
}
}
else
{
if(studentAnswer == answer)
{
printCorrectAnswer();
break;
}
else
{
printWrongAnswer();
}
}
}while(1);
}
int main()
{
int questionsCount = 0;
do
{
printf("\n1. Addition problems\n2. Subtraction problems \n3.
Multiplication problems\n4. Division problems\n5. Mixed\n6.
Terminate");
int problemType = 0;
do
{
printf("\nPick your problem (1 to 5) or 6 to terminate: ");
scanf("%d", &problemType);
if(problemType == 6) return 0; // terminate the program.
if(problemType < 1 && problemType > 5)
{
printf("That's an invalid input.");
}
else break;
}while(1);
int difficultyLevel = 0;
do
{
// lets limit to 3 levels.
printf("\nEnter difficulty level (1 to 3): ");
scanf("%d", &difficultyLevel);
if(difficultyLevel < 1 && difficultyLevel > 3)
{
printf("That's an invalid input.");
}
else break;
}while(1);
while(questionsCount < 10)
{
getQuestion(problemType, difficultyLevel);
questionsCount++;
}
int totalAnswers = rightAnswers + wrongAnswers;
if((float)rightAnswers / totalAnswers < 0.75)
{
printf("\nPlease ask your teacher for extra help.");
}
else
{
printf("\nCongratulations you are ready to go to the next
level");
}
questionsCount = 0;
rightAnswers = 0;
wrongAnswers = 0;
}while(1);
return 0;
}
Sample output:
Please put the outputs with it also I want to make sure it runs thanks Project-Computer-Assisted...
Android / Java / Please Upload your homework. Copy the screenshot and then paste it to this word document. Then zip your word file and java files. Note: if your android project is too big, you can just zip all of the needed xml files and java files. Computer-Assisted Instruction App) Create an app that will help an elementary school student learn multiplication. Select two positive one-digit integers. The app should then prompt the user with a question, such as...
Problem (Computer Assisted Instruction) The use of computers in education is referred to as Computer Assisted Instruction (CAI). Develop a Java application that can help an elementary school student learn division of two decimal integer numbers. When the application is launched, its behaviour should be like as described: 1. The application should welcome the learner and ask if ready to learn the topic. Assume the application can assist only to learn division of two integer numbers. 2. If the user...
Programming in C: Write a program that will help an elementary school student learn multiplication. Use the random number generator to produce two positive integers between 1 and 12 inclusive. It should then type a question such as: How much is 6 times 7? The student then types the answer. Your program checks the students’ answer. If it is correct, print a message such as Very good! If the answer is wrong, print a message such as No. Please...
Write a JAVASCRIPT program that will help an elementary school student learn multiplication. Use the Random method to produce two positive one-digit integers. The program should then prompt the user with a question using random numbers, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it is correct, display the message "Very good!" and ask whether the student wants to continue if so then ask another multiplication...
So I can not get this to work properly and he does not want us using an array list. Below is the directions along with the code I have(Im not sure the code is in the right format) ITSE 2321 – OBJECT-ORIENTED PROGRAMMING JAVA Program 7 – Methods: A Deeper Look Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers. The program should then prompt the student...
Java Programming Write a program that will help a student learn multiplication. Use SecureRandom object to produce two positive integers between 1 and 20. The program should then prompt the user with a question (use a sentinel-controlled loop), such as: How much is 10 times 11? The student then inputs the answer. If the answer is correct display the message “very good” and ask another question. If the answer is wrong to display the message “no, please try again” and...
Write a program that will help a student learn multiplication. Use SecureRandom object to produce two positive integers between 1 and 20. The program should then prompt the user with a question (use a sentinel-controlled loop), such as: How much is 10 times 11? The student then inputs the answer. If the answer is correct display the message “very good” and ask another question. If the answer is wrong to display the message “no, please try again” and let the...
Need urgently.Plz use math.random() formula for random numbers and show the output as recquired. Problem (Computer Assisted Instruction) The use of computers in education is referred to as Computer Assisted Instruction (CAI). Develop a Java application that can help an elementary school student learn division of two decimal integer numbers. When the application is launched, its behaviour should be like as described: 1. The application should welcome the learner and ask if ready to learn the topic. Assume the application...
Instructions Basically, you will modify the mathq program to make it satisfy a different set of requirements, and fix what is not working in it. Specifically, imagine that the client for whom we created the mathq program for would now like some changes. To be exact: Part 1: They want it to provide addition and subtraction problems as well as multiplication and division. They still want the choice to be random, as before, but now the problem is randomly multiplication,...
Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write a program that will help an elementary school student to learn English. To simplify the model, the program will first teach numbers from 1 to 10, colors and fruits. It will use a dictionary to store the pairs Spanish-English words. dataTable-uno':one,'dos':'two....' rojo':'red','blue':'Azul... manzana': apple, nara nja:orange. When running your program, it should get a random Spanish word from the dictionary dataTable and then show...