Deitel & Deitel, C How to Program 6th Edition, Exercise 5.51 - 5.52 - 5.53 - 5.54 (Computer - Assisted Instruction)
/*5.51 (Computer-Assisted Instruction: Reducing Student Fatigue) One problem in CAI environments
is student fatigue. This can be reduced by varying the computer’s responses to hold the student’s
attention. Modify the program of Exercise 5.50 so that various comments are displayed for
each answer as follows:
Possible responses to a correct answer:
Very good!
Excellent!
Nice work!
Keep up the good work!
Possible responses to an incorrect answer:
No. Please try again.
Wrong. Try once more.
Don't give up!
No. Keep trying.
Use random-number generation to choose a number from 1 to 4 that will be used to select
one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to
issue the responses.
5.52 (Computer-Assisted Instruction: Monitoring Student Performance) More sophisticated
computer-assisted instruction 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 program of Exercise 5.51 to count the number of correct and incorrect responses typed by the
student. After the student types 10 answers, your program should calculate the percentage that are
correct. If the percentage is lower than 75%, display "Please ask your teacher for extra help.",
then reset the program so another student can try it. If the percentage is 75% or higher, display
"Congratulations, you are ready to go to the next level!", then reset the program so another
student can try it.
5.53 (Computer-Assisted Instruction: Difficulty Levels) Exercise 5.50 through Exercise 5.52 developed
a computer-assisted instruction program to help teach an elementary school student multiplication.
Modify the program to allow the user to enter a difficulty level. At a difficulty level of 1,
the program should use only single-digit numbers in the problems; at a difficulty level of 2, numbers
as large as two digits, and so on.
5.54 (Computer-Assisted Instruction: Varying the Types of Problems) Modify the program of
Exercise 5.53 to allow the user to pick a type of arithmetic problem to study. An option of 1 means
addition problems only, 2 means subtraction problems only, 3 means multiplication problems only
and 4 means a random mixture of all these types.*/
#include <stdio.h>
#include <stdlib.h>
int operations(char, int);
int rightCount, wrongCount;
enum correction { RIGHT, WRONG };
int main() {
int i, answers = 0, typ;
char diff;
printf("Which operation do you want to work on?\n");
printf("Enter (1) for Addition\n");
printf("Enter (2) for Subtraction\n");
printf("Enter (3) for Multiplication\n");
printf("Enter (4) for Division\n");
printf("Enter (5) for All Four\n==> ");
scanf("%d", &typ);
printf("Choose a difficulty level\n");
printf("(EASY) : Enter E\n");
printf("(MEDIUM) : Enter M\n");
printf("(HARD) : Enter H\n\n==> ");
diff = getchar();
diff = getchar();
for (i = 1; i <= 10; i++) {
answers = operations(diff, typ) + answers;
if (answers >= 5) {
wrongCount == 0 ? wrongCount = 1 : 0;
if (rightCount / wrongCount <= 3)
printf("Your success is under 75%%\nPlease ask your teacher for extra help.\n");
else
printf("Congratulations, your success rate is over 75%% you are ready to go to the next level!\n");
break;
}
}
return 0;
}
int operations(char difficulty, int type) {
int num1, num2, ans, promt, answerCount = 0, k;
enum correction status = WRONG;
type == 5 ? type = rand() % 4 + 1 : 0;
switch (type) {
case 1:
case 2:
case 3:
switch (difficulty) {
case 'E':
num1 = rand() % 10;
num2 = rand() % 10;
break;
case 'M':
num1 = rand() % 90 + 10;
num2 = rand() % 10;
break;
case 'H':
num1 = rand() % 90 + 10;
num2 = rand() % 90 + 10;
break;
}
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
break;
case 4:
switch (difficulty) {
case 'E':
do {
num1 = rand() % 10 + 1;
num2 = rand() % 9 + 1;
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
} while (num1 % num2 != 0);
break;
case 'M':
do {
num1 = rand() % 90 + 10;
num2 = rand() % 10;
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
} while (num1 % num2 != 0);
break;
case 'H':
do {
num1 = rand() % 90 + 10;
num2 = rand() % 90 + 10;
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
} while (num1 % num2 != 0);
break;
}
break;
}
printf("Here is a question for you!\n");
while (status == WRONG) {
switch (type) {
case 1:
printf("%d + %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1 + num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
case 2:
printf("%d - %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1 - num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
case 3:
printf("%d * %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1*num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
case 4:
printf("%d / %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1 / num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
}
promt = rand() % 4;
if (status == RIGHT) {
switch (promt) {
case 0:
printf("Very good!\n\n");
break;
case 1:
printf("Excellent!\n\n");
break;
case 2:
printf("Nice work!\n\n");
break;
case 3:
printf("Good work!\n\n");
break;
}
rightCount++;
}
else {
switch (promt) {
case 0:
printf("No. Please try again!\n");
break;
case 1:
printf("Wrong. Try once more!\n");
break;
case 2:
printf("Don't give up!\n");
break;
case 3:
printf("No keep trying!\n");
break;
}
printf("\n");
wrongCount++;
}
}
return answerCount;
}
is student fatigue. This can be reduced by varying the computer’s responses to hold the student’s
attention. Modify the program of Exercise 5.50 so that various comments are displayed for
each answer as follows:
Possible responses to a correct answer:
Very good!
Excellent!
Nice work!
Keep up the good work!
Possible responses to an incorrect answer:
No. Please try again.
Wrong. Try once more.
Don't give up!
No. Keep trying.
Use random-number generation to choose a number from 1 to 4 that will be used to select
one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to
issue the responses.
5.52 (Computer-Assisted Instruction: Monitoring Student Performance) More sophisticated
computer-assisted instruction 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 program of Exercise 5.51 to count the number of correct and incorrect responses typed by the
student. After the student types 10 answers, your program should calculate the percentage that are
correct. If the percentage is lower than 75%, display "Please ask your teacher for extra help.",
then reset the program so another student can try it. If the percentage is 75% or higher, display
"Congratulations, you are ready to go to the next level!", then reset the program so another
student can try it.
5.53 (Computer-Assisted Instruction: Difficulty Levels) Exercise 5.50 through Exercise 5.52 developed
a computer-assisted instruction program to help teach an elementary school student multiplication.
Modify the program to allow the user to enter a difficulty level. At a difficulty level of 1,
the program should use only single-digit numbers in the problems; at a difficulty level of 2, numbers
as large as two digits, and so on.
5.54 (Computer-Assisted Instruction: Varying the Types of Problems) Modify the program of
Exercise 5.53 to allow the user to pick a type of arithmetic problem to study. An option of 1 means
addition problems only, 2 means subtraction problems only, 3 means multiplication problems only
and 4 means a random mixture of all these types.*/
#include <stdio.h>
#include <stdlib.h>
int operations(char, int);
int rightCount, wrongCount;
enum correction { RIGHT, WRONG };
int main() {
int i, answers = 0, typ;
char diff;
printf("Which operation do you want to work on?\n");
printf("Enter (1) for Addition\n");
printf("Enter (2) for Subtraction\n");
printf("Enter (3) for Multiplication\n");
printf("Enter (4) for Division\n");
printf("Enter (5) for All Four\n==> ");
scanf("%d", &typ);
printf("Choose a difficulty level\n");
printf("(EASY) : Enter E\n");
printf("(MEDIUM) : Enter M\n");
printf("(HARD) : Enter H\n\n==> ");
diff = getchar();
diff = getchar();
for (i = 1; i <= 10; i++) {
answers = operations(diff, typ) + answers;
if (answers >= 5) {
wrongCount == 0 ? wrongCount = 1 : 0;
if (rightCount / wrongCount <= 3)
printf("Your success is under 75%%\nPlease ask your teacher for extra help.\n");
else
printf("Congratulations, your success rate is over 75%% you are ready to go to the next level!\n");
break;
}
}
return 0;
}
int operations(char difficulty, int type) {
int num1, num2, ans, promt, answerCount = 0, k;
enum correction status = WRONG;
type == 5 ? type = rand() % 4 + 1 : 0;
switch (type) {
case 1:
case 2:
case 3:
switch (difficulty) {
case 'E':
num1 = rand() % 10;
num2 = rand() % 10;
break;
case 'M':
num1 = rand() % 90 + 10;
num2 = rand() % 10;
break;
case 'H':
num1 = rand() % 90 + 10;
num2 = rand() % 90 + 10;
break;
}
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
break;
case 4:
switch (difficulty) {
case 'E':
do {
num1 = rand() % 10 + 1;
num2 = rand() % 9 + 1;
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
} while (num1 % num2 != 0);
break;
case 'M':
do {
num1 = rand() % 90 + 10;
num2 = rand() % 10;
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
} while (num1 % num2 != 0);
break;
case 'H':
do {
num1 = rand() % 90 + 10;
num2 = rand() % 90 + 10;
if (num2 > num1) {
k = num2;
num2 = num1;
num1 = k;
}
} while (num1 % num2 != 0);
break;
}
break;
}
printf("Here is a question for you!\n");
while (status == WRONG) {
switch (type) {
case 1:
printf("%d + %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1 + num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
case 2:
printf("%d - %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1 - num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
case 3:
printf("%d * %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1*num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
case 4:
printf("%d / %d = ", num1, num2);
scanf("%d", &ans);
answerCount++;
if (num1 / num2 == ans)
status = RIGHT;
else
status = WRONG;
break;
}
promt = rand() % 4;
if (status == RIGHT) {
switch (promt) {
case 0:
printf("Very good!\n\n");
break;
case 1:
printf("Excellent!\n\n");
break;
case 2:
printf("Nice work!\n\n");
break;
case 3:
printf("Good work!\n\n");
break;
}
rightCount++;
}
else {
switch (promt) {
case 0:
printf("No. Please try again!\n");
break;
case 1:
printf("Wrong. Try once more!\n");
break;
case 2:
printf("Don't give up!\n");
break;
case 3:
printf("No keep trying!\n");
break;
}
printf("\n");
wrongCount++;
}
}
return answerCount;
}
Let me know in the comments if this page helped you somehow.
It is nice to know if my work helped someone, thanks :)
Comments
Post a Comment