so I have to write a code for this question:
Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline. Example output for numCycles = 2:
1: Lather and rinse.
2: Lather and rinse.
Done.
Hint: Declare and use a loop variable.
but what I've gotten so far is giving me errors and im not sure what im doing wrong. Can someone help me fix my code?
Are you allowed to use an IDE (Integrated Development Environment) or are you coding in something like Notepad?
An IDE like IntelliJ will catch typo errors like this for you.
I usually use eclipse IDE but this one was out of thee book so I didn't write it in there. Anyways I fix it, thanks for thee help that's all it was lol.
I would makr you down for writing your loop like that. Remember the default format for a for loop is there for a good reason: it works.The + will work as expected because all +s are to the left of the String literal. You can move the ++ into the loop like this:-
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, the permaculture playing cards