Multiplication program

My stepdaughter Samantha is in fourth grade. She recently learned to do multiplication of long numbers. She learned this with a trick that I'd never seen before. This new method was so interesting to my that I decided to write a Java version of this technique for you to play with. I hope you find it interesting too.

How it works

You can see the stages of setting up the problem by clicking on the three radio buttons on the right side of the applet. First, you write out the two numbers that are being multiplied together. One number goes across the top, the other goes down the right side. Then you draw a rectangular grid for the digits of the numbers. So if you are multiplying two three-digit numbers together, you will have a 3x3 grid. Finally, you draw diagonal lines from the top and right edges of the grid, bringing them down towards the lower left. This is how the problem is set up.

Now you have a bunch of rows and columns each corresponding to one digit from your two numbers. In each box, multiply the row and column digits together and you will get a one or a two digit number. Write the first digit of the result in the top left corner, and the second digit in the bottom right corner. If it is a one digit number, write "0" in the top left.

To obtain the final answer, you do an addition problem. Begin at the bottom right corner. Moving down and left, add up the numbers in the grid (there will be only one digit to add the first time) and write your answer at the end of the area enclosed by the diagonal lines. Now move one column up and left and repeat the process, this time adding three numbers. Continue until all the numbers on the bottom and left sides are filled in. Rules of carrying digits apply as in normal addition.