CIT 591 Assignment 1: Multiplication Table
Fall 2004, David Matuszek

Purposes of this assignment:

General idea of the assignment:

Create and display, in a JApplet, a multiplication table for the numbers 1 through 10. Your running JApplet should look something like this.


Your applet should look more or less like the above, but it doesn't have to look exactly the same--it just has to be fairly neat.

You will find that there is a lot of arithmetic involved in creating this applet--not in doing the multiplications (that part is trivial), but in figuring out exactly where to put the lines and the numbers. You and your partner will have to agree on things like how far apart the lines are.

Hint: You can turn a number into a String by concatenating it with the empty string (n + "").

Experiment a bit with color. In the example, I drew all the square numbers in red.

Here is a simple JApplet to get you started:

import javax.swing.JApplet;
import java.awt.*;

public class Drawing extends JApplet {

    public void paint(Graphics g) {
    private void paintFirst(Graphics g) {
        g.fillRect(20, 20, 50, 30);
    private void paintSecond(Graphics g) {
        g.fillRect(50, 30, 50, 30);

This program is to be written with a partner, if at all possible. There are various tasks to be done; here is one possible division of labor:

You don't have to do it exactly this way, as long as you and your partner agree, and each of you does part of the work. If you use the above starter code, one person could replace the code in the paintFirst method, and the other replace the code in the paintSecond method. Alternatively, you might decide to put all your code into the paint method.

Do draw all lines and all numbers in loops. You should not have a long list of similar commands, one for each line or each number.

Display your names underneath the table. If there is a clear division of who did what, you can indicate that fact there, but you don't have to.


The more Java you know, the better. I am not one of those instructors that insist you can't use something until I've covered it in class! However...there are two caveats:


Grading on all programs is out of 100%. Programs with syntax errors automatically get zero. Some grading factors are subjective, such as whether your multiplication table is neatly drawn, and whether your code uses good indentation and variable names.

You and your partner will each receive the same grade on this assignment, no matter how you split up the work.

For various reasons, you don't generally get to pick your partner. I assign partners. I try to ensure that you work with a different partner each week.

Due date:

Thursday, Sept. 16, before midnight. Turn in your zipped assignment via Blackboard -- see Instructions for Using Zip Files and Blackboard for instructions. Your program should be ready to run under BlueJ, so include the files that BlueJ generates, along with your .java and .class files. Be sure to Submit File, not Add File! Programs submitted any other way will not be accepted.

Just turn in one program for the two of you, please; whoever turns it in, please put your partner's name in the Blackboard comments field.


Do not turn in a program with any untested changes, even if you (think you) only changed something in a comment. If you make any last-minute changes, test them before you submit the program.

If a program doesn't work at all, don't turn it in. You'll just get a zero anyway, and you'll be wasting our time. Fix it and turn it in late. If you decide, after you have turned in a program, that you need to make changes and turn in a corrected version, it's OK to do so--just don't do this too often, because grading programs can be a lot of work. Of course, re-submitted programs after the due date will get late points taken off.