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.
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!