| | |
How do you output in two columns?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 8
Reputation:
Solved Threads: 0
Annual Interest Rate Monthly Payment
11.00 952.32
11.25 971.26
11.50 990.29
11.75 1009.41
12.00 1028.61
I've done the hard part and completed the project, but I can't figure out how to get my program to output in two columns like above. Since this site doesn't take spacing, black column is one column and the red is the other column. Do you just wing it and add a bunch of spaces in or is there a proper way to do it?
11.00 952.32
11.25 971.26
11.50 990.29
11.75 1009.41
12.00 1028.61
I've done the hard part and completed the project, but I can't figure out how to get my program to output in two columns like above. Since this site doesn't take spacing, black column is one column and the red is the other column. Do you just wing it and add a bunch of spaces in or is there a proper way to do it?
Last edited by Amurka; Nov 5th, 2007 at 6:04 pm.
The Java Tutorials - String
•
•
•
•
Using String's static format() method allows you to create a formatted string that you can reuse, as opposed to a one-time print statement. For example, instead of
Java Syntax (Toggle Plain Text)
System.out.printf("The value of the float variable is %f, while the value of the " + "integer variable is %d, and the string is %s", floatVar, intVar, stringVar);
you can write
Java Syntax (Toggle Plain Text)
String fs; fs = String.format("The value of the float variable is %f, while the value of the " + "integer variable is %d, and the string is %s", floatVar, intVar, stringVar); System.out.println(fs);
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
As long as the first String is always of the same length and does not vary over the "tabStop index" length. printf (if you're using a late enough version of it) is, of course, the proper way to do this.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Output Windows Explorer column details to a file (Windows NT / 2000 / XP)
- Open In New Window Php (PHP)
- Program Seems to be right but still some confusion on output into columns (C++)
- Script stores data in wrong MySQL columns (MySQL)
- problem printing output (C++)
Other Threads in the Java Forum
- Previous Thread: Rename directory in ant build script
- Next Thread: Java Mailing
| Thread Tools | Search this Thread |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component database db defaultmethod development dice dragging draw ebook eclipse error event exception formatingtextintooltipjava fractal game givemetehcodez graphics gui html ide image infinite input integer invokingapacheantprogrammatically j2me java javaprojects jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie numbers openjavafx oracle parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads time tree windows






