This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hello all, I wrote a simple program that display a pattern of numbers
You can see the output through running as it has spaces before numbers and the page doesn't allow spaces to be
displayed before numbers.
well, all i need in this program is that i want to insert space between numbers
and the pattern remain as it is.
I'd be grateful if you give me any notes about my program
I Hear I Forget, I See I Remember, I Do I Understand.
Note that since each 'number' will now take two positions (one for the digit, and one for the space) you may need to print two spaces instead of one on your line 11, depending on what you want the actual output to look like.
also, this will have problems if your '6' changes to something larger than '9'.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
part of the problem is that you have to know how much space you need before you print your first line. I.e., if the biggest number is one digit, you only need one space. if the biggest is 2 digits, you need two spaces for the first few numbers, then only one.
if your biggest number is 3 digits, you'll need to pad three spaces for the first few, then two spaces for the next 90, then 1 space...
Of course, I'm just guessing here, since I don't know what you are REALLY trying to do. What is your actual goal/what do your actual specs say?