Thursday, October 28, 2010

How do I create a multiplication table in Java using a for loop?

I need to create a multiplication table in Java, and I am supposed to use a for loop. The application needs to ask the user for a starting number and an ending number. It should then create a multiplication table that multiplies each of those by 1 to 10.

So it should list the numbers between the start and the end vertically, and horizontally it should have those numbers multiplied by 1 to 10. Each number should be seperated by a tab.



Thank you.

:]How do I create a multiplication table in Java using a for loop?
This sounds like a homework assignment that you're asking for help on. However, I'm not one to judge. Here is the algorithm

// The max for the left section of the table

int x;

// The max for the top section of the table

int y;



for(int temp1 = 1; temp1 %26lt; x; temp1++)

{

for(int temp2 = 1; temp2 %26lt; y; temp2++)

{

System.out.print((temp1 * temp2) + '\t');

}

System.out.println();

}





I'll let you figure out how to print the numbers on the top and the left. I'm assuming this is a homework assignment, so I can't do the whole thing for you

No comments:

Post a Comment