Zeused Posted May 7, 2019 Share Posted May 7, 2019 I am currently learning loops (just finished for loops, or at least the basics of it) and working on while loops. was wondering if someone could help me out? (must be used with while loop, even though it can be solved with for loop). it is pretty basic, but anything relating to while loops really flies over my head. integer n is equal to the amount of stars are returned, so the returning value is a string and I think it will continue on at an infinite rate, although idk if codingbat will enjoy that. ive been using cloud9 (although support is gone at 2020) so I don't mind hardcoding it as well. Quote Link to comment Share on other sites More sharing options...
Ryze Posted May 7, 2019 Share Posted May 7, 2019 String output = ""; int i = 0; while (i < n) { output += "*"; } return output; 1 Quote Link to comment Share on other sites More sharing options...
Zeused Posted May 23, 2019 Author Share Posted May 23, 2019 sort of a late reply but ive got another problem lol. I did some editing from your setup and came up with this (which worked). I don't think codingbat liked the infinite loop, so it would say "timed out", so I had to limit it. String output = ""; int i = 0; while (i < n) { output = output + "*"; i = i+1; } return output; } anyways ive got another problem, and yet again it returns a string. this one is a little harder, but I can use for loops for it, but the input is a string. (ive never used strings for an input in a for loop before, just integers and doubles) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.