I am taking my first programming class online and don't have a lot of access to the teacher. This week we are supposed to write code which will in essence print a calendar. I am stuck at getting my numbers to print in a horizontal line. Please help.
Printable View
I am taking my first programming class online and don't have a lot of access to the teacher. This week we are supposed to write code which will in essence print a calendar. I am stuck at getting my numbers to print in a horizontal line. Please help.
There are two printing methods that you'll commonly use:
System.out.println(someString): which prints a String and then a new-line, and
System.out.print(someString): which prints a String but no new-line. You can use this to print several things on one line.
Also, consider looking into using System.out.printf(...): which can be useful for printing formatted output. There are decent tutorials easily found on Google which will explain how this works.
Thanks, that helped. I used the System.out.print() and got my output in a horizontal, which is what I wanted. Now I need to limit the number of characters to 7, then go to the next line. I have tried different things and have been able to stop at seven, continue on the next line, but each line after the first printed 8 characters (I did that once, about 2 hours ago, but can't remember how I did it. It had something to do with the '%' symbol). I'm a little frustrated and would appreciate any help.