I found an exercise i m having trouble completing on my own .The exercise sounds like this :
Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid , as shown in the following sample run (my code displays correctly the first 9 lines):
The problem is when i input a number greater then 9 as it requires 2 spaces . I m pritty sure i solved it incorrectly or at lost not optimal as i m using a string that decreases on each line to create the pyramid effect.
You can improve that no end by printing a single String a certain number of times before your numbers.Because multiple print calls are slow, I would suggest you consider putting the whole thing into a StringBuilder, then you can print out the entire StringBuilder as one print call.