homework... sorry :o(
annoying/boring/newbie post - i'm sorry :o(
intro level student and i'm stuck on something that's probably laughable to all you experienced people... but it's driving me nuts and i can't be spending days on 1 question! so i'm just gonna post it and see if someone can possibly tell me what i'm doing wrong!
our class uses the website turingscraft for practice "homework questions" where a question pops up, you type in your answer, and it tells you if it's correct or incorrect, sometimes giving you hints.
this is the question:
Given an int variable n that has already been declared and initialized to a positive value, use a while loop to print a single line consisting of n asterisks. Use no variables other than n .
this is what i've typed..
while (n>0) {
System.out.println('*' * n);
n--;
}
i've also tried about a million variations, some of them being:
while (n>0) {
System.out.println('*');
n++;
}
and
while (n==n) {
System.out.println('*' * n);
n--;
}
it either tells me that i need to print a single line only, or it tells me i've sent it into an infinite loop... can *anyone* tell me what am i typing wrong? you will cause me much relief if so
intro level student and i'm stuck on something that's probably laughable to all you experienced people... but it's driving me nuts and i can't be spending days on 1 question! so i'm just gonna post it and see if someone can possibly tell me what i'm doing wrong!
our class uses the website turingscraft for practice "homework questions" where a question pops up, you type in your answer, and it tells you if it's correct or incorrect, sometimes giving you hints.
this is the question:
Given an int variable n that has already been declared and initialized to a positive value, use a while loop to print a single line consisting of n asterisks. Use no variables other than n .
this is what i've typed..
while (n>0) {
System.out.println('*' * n);
n--;
}
i've also tried about a million variations, some of them being:
while (n>0) {
System.out.println('*');
n++;
}
and
while (n==n) {
System.out.println('*' * n);
n--;
}
it either tells me that i need to print a single line only, or it tells me i've sent it into an infinite loop... can *anyone* tell me what am i typing wrong? you will cause me much relief if so
