aspose file tools*
The moose likes Beginning Java and the fly likes Program that displays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program that displays " 6 times" table" Watch "Program that displays " 6 times" table" New topic
Author

Program that displays " 6 times" table

Timothy Willis
Greenhorn

Joined: Nov 13, 2004
Posts: 4
Hi,

I'm very new to java and programming.

Using a for loop i want to write a program that displays a "6 times" multiplication table; something like this:

1 x 6 = 6
2 x 6 = 12
3 x 6 = 18
.............
.............
12 x 6 = 72


Can anyone show me how to do this please? Thanks.
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
Well, we try not to "show" you how to do it as much as get you to figure it out. First off, what is a for loop? What values do you want it to loop through? What do you want to do with these values?
If you have a firm understanding of the for loop, this program is pretty simple.


I've heard it takes forever to grow a woman from the ground
Lou Bassett
Greenhorn

Joined: Nov 08, 2004
Posts: 13
A FOR loop has an iterator variable- something that gets incremented each time through the loop (ie. 1,2,3 ...). Think about using it in the body of the code to help you out.


Lou Bassett
Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
The following code will display the 2's, 3's 4's and 5's.

Hope this is a good example for you to build on.

public class Repetition
{
public static void main(String [ ] args)
{
int table, multiplier;

for (table = 2; table<5; table++)
{
//Print out the heading
System.out.println("\nMultiplication table for : "
+ table + " 's");
for(multiplier = 1; multiplier<=10; multiplier++)
{
System.out.print( (multiplier * table) + " \t");
}

}
System.out.println("\nLoops finished\n")
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program that displays " 6 times" table