• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

formatting a multiplication table with printf

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
You got style baby! More than this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic