
-----------------------------------
hamid14
Sun Nov 21, 2010 1:56 pm

convert int into number of spaces
-----------------------------------
I have a variable int space, my program asks user to enter space, it can be any number from 1 to 10, including 1 and 10. I want to convert that number into a string, but say 1 = 1 space, so 1 = " " and then 2 = 2 spaces, so 2 = "  "

i have to do this without using if or switch statements. any help is appreciated. thanks

-----------------------------------
andrew.
Sun Nov 21, 2010 2:35 pm

RE:convert int into number of spaces
-----------------------------------
Well, you have the number of spaces needed, so you just have to loop through them from 1 to the number and print the spaces all on one line (i.e. System.Out.Write(" ");).

Can you think of something that can do the bolded words? Loop from a number to another number.

-----------------------------------
hamid14
Sun Nov 21, 2010 4:34 pm

Re: convert int into number of spaces
-----------------------------------
im thinking for loop, but ill try it out when i have netbeans thanks
