This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes formatting a multiplication table with printf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "formatting a multiplication table with printf" Watch "formatting a multiplication table with printf" New topic

formatting a multiplication table with printf

jordan leach

Joined: Mar 25, 2013
Posts: 1
Hello all,

I am having trouble with a java program in which I have to use the printf method in order to allow my program to print the program in neat columns that aligns all the numbers properly.

I have written the code that prints all of the numbers, so now I just have to add in the printf's that will clean the columns up.

Here is the code that I have so far:

I have tried changing the specific the sys.o.print lines to sys.o.printf then beginning the statements with things like %d30 in hopes of setting each line to 30 characters wide but all that did was extend all of the rows to be 30 characters long.
Greg Charles

Joined: Oct 01, 2001
Posts: 2969

Hi Jordan,

Welcome to JavaRanch!

First, please UseCodeTags (⇐Click to see our FAQ entry). They make code samples so much easier to read.

Second, you say you are having trouble with printf, but you haven't said what the trouble is. Can you be a little more clear? The problem is that after a while here at the Ranch, we tend to get jaded and cynical, and are apt to think people are just posting homework assignments and asking us to do it for them. Believe me, it happens! So, show us what you've tried with printf, and tell us what's not working. Then we'll see if we can get you pointed in the right direction!
I agree. Here's the link:
subject: formatting a multiplication table with printf
jQuery in Action, 3rd edition