Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 convert int into number of spaces
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hamid14




PostPosted: Sun Nov 21, 2010 1:56 pm   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Sun Nov 21, 2010 2:35 pm   Post subject: 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(" ")Wink.

Can you think of something that can do the bolded words? Loop from a number to another number.
hamid14




PostPosted: Sun Nov 21, 2010 4:34 pm   Post subject: Re: convert int into number of spaces

im thinking for loop, but ill try it out when i have netbeans thanks
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: