Sie sind auf Seite 1von 6

PROBLEM SOLVING AND COMPUTER

PROGRAMMING

Lecture 05:
Lecture 16:
Development of Elementary School
Arithmetic Testing System

NITW – PSCP 16 1
Elementary School Arithmetic System - I
• Write a program that develops an elementary school
Arithmetic testing system.
– Select an operation to perform.
– Use rand() (function of <cstdlib> library) to produce two single digit
numbers.
– Then it should type a question such as
– How much is 8 plus 1?
– The student then types the answer. Your program checks the student's
answer.
– If it is correct, print "Very good!",
– If the answer is wrong, print "No. Please try again.",
– then let the student try the same question repeatedly until the
student finally gets it right.

NITW – PSCP 16 2
Elementary School Arithmetic System – I

Output of the program should be like:


– How much is 8 plus 2?
–9
– "No. Please try again.“
– 11
– "No. Please try again.“
– 10
– “Very good!“

NITW – PSCP 16 3
Elementary School Arithmetic System - II
• One problem that develops in previous environments is
student fatigue.
• This can be eliminated by varying the computer's dialogue to
hold the student's attention.
• Modify the program so that various comments are printed for
each correct answer and each incorrect answer as follows:
• Responses to a correct answer
– Very good!
– Excellent!
– Nice work!
– Keep up the good work!

NITW – PSCP 16 4
Elementary School Arithmetic System - II
• Responses to an incorrect answer
– No. Please try again.
– Wrong. Try once more.
– Don't give up!
– No. Keep trying.

• In order to print those varying dialogues:


– Use the random number generator to choose a number
from 1 to 4 to select an appropriate response to each
answer.
– Use a switch statement to issue the responses.

NITW – PSCP 16 5
Elementary School Arithmetic System - III
• More sophisticated Elementary School Arithmetic systems
monitor the student's performance over a period of time.
• The decision to begin a new topic often is based on the
student's success with previous topics.
• Modify the program 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 of correct responses.
• If the percentage is lower than 75 percent, your program
should print "Please ask your instructor for extra help" and
terminate.

NITW – PSCP 16 6

Das könnte Ihnen auch gefallen