Assignment 5
Assigned Tuesday, November 5; Due Tuesday, November 12, 5pm
The Problem
(This is exercise 4.30 in our text book.) Write an applet, called MathTutor, that would help an elementary school
student learn the multiplication tables. Use Math.random to produce 2 positive 1-digit integers. It then should display
a question in the status bar such as:
How much is 6 times 7?
The student then types the answer into a TextField. Your program checks the student's answer. If it is correct, draw
the string "Very good!" on the applet. Then, ask another multiplication question. If the answer is wrong, draw the
string "No. Please try again." on the applet. Then, let the student try the same question again, repeatedly, until the
student gets it right. A separate method should be used to generate each new question. This method should be called
once when the applet begins execution, and each time the user answers the question correctly. All drawing on the applet
should be preformed by the paint method.
Optional challenge
For those so inclined, here are 2 ways that you can enhance the function of your applet (you can choose to do either,
both, or none):
- Allow the user to enter a grade-level capability. A grade level of 1 means use only single-digit numbers in the
problems; level of 2 mean use numbers as large as 2 digits, etc. up to 4.
- Allow the user to pick the type of arithmetic problems he or she wishes to study.
- An option of 1 means only addition problems;
- An option of 2 means only subtraction problems;
- An option of 3 means only multiplication problems;
- An option of 4 means only division problems;
- An option of 5 means randomly mix problems of all these types.
Turn In Procedure
- Email your Java source file to cs10@cs.ucsb.edu. Emailing to the wrong address is not an acceptable reason for
a late turn-in. Be sure to email your file while logged into your own account. To test your applet, we will use an
applet whose width and height is 300.
- Submit a hard copy of your Java source file to the CS10 homework box (on the 2nd floor of Engineering I, next to
the Computer Science Departmental office).