There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
Third exercise says that The 1 in this statement should correspond with the current value of cupsOfCoffee . When cupsOfCoffee is 100 , this should be printed: “Fry drinks cup of coffee #100”.
I was trying:
while (cupsOfCoffee <= 100){
System.out.println(“Fry drinks cup of coffee #1”);
cupsOfCoffee++;
}
Which was obviously printing only “Fry drinks cup of coffee #1” , 100 times.
So I changed to:
while (cupsOfCoffee <= 100){
System.out.println("Fry drinks cup of coffee " + cupsOfCoffee);
cupsOfCoffee++;
}
And this works! Increasing the fry drinks cup of coffee by 1 in every line. The exercise still says something is wrong??? I cant press next even though my code is right. Help?
I think that it is fairly common to review your code character by character and even delete and retype every dot, comma, colon and semicolon. Commas may look sometimes like dots from a distance and they have caused odd errors for me sometimes.
For any Futurama freak: this exercise is a loop based on the 100 coffee futurama episode where Fry spend 300 USD in coffees and after the 100 coffee he can move fast as the flash (and then he saves the world hehe). You can make it funnier adding a final quote like System.out.println(“Fry is faster than flash”).
I did exactly the samething!, I am really enjoying CodeAcademy but every now & then they ask you to do an exercise & have not covered all bases e.g the exercise clearly states print “Fry drinks cup of coffee #1” so of course this is what we will set to print because we dont know any better as new learners, good thing is you can view solution & it maybe a typo for the number 1 added after the # key.
So I got everything correct and am able to advance, but Fry is drinking 101 cups, and I can’t figure out why!
class Coffee {
public static void main(String[] args) {
// initialize cupsOfCoffee
int cupsOfCoffee = 1;
// add while loop with counter
while (cupsOfCoffee <= 100) {
System.out.println("Fry drinks cup of coffee #" + cupsOfCoffee);
cupsOfCoffee++;
}
System.out.println("Fry drinks cup of coffee #" + cupsOfCoffee);
}
}