Posted By: Anonymous
I am newer to programming and taking an online Java class. I’m making a table that prints out Fahrenheit to Celsius and Celsius to Fahrenheit on the same line. I am supposed to use System.out.format for this problem. But I can only get it to print the first column. This is my System.out.format line:
System.out.format("%3.3f", fahrenheit, fahToCel, "|", celsius, celToFah);
What am I doing wrong?
I can add more code if needed and I hope I explained this problem properly.
format takes a single format string, then a list of objects to use to ‘fill in’ the string.
In your case I imagine you want something like
System.out.format("%3.3f %3.3f|%3.3f %3.3f", fahrenheit, fahToCel, celsius, celToFah);