Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsFinal Challenge C#
Hey guys and girls, I am having trouble with the Final challenge task 1. Can someone tell me what is wrong in my code?
Thanks.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
int entry = Console.Write("Enter the number of times to print \"Yay!\": ");;
while (entry == 5) {
Console.WriteLine("Yay!" + " Yay!" + " Yay!" + " Yay!" + " Yay!");
}
}
}
}
1 Answer
Jon Wood
9,884 PointsYou are only handling the scenario when entry
is 5. You need to be able to handle different entries a user may input. If you're comfortable with it, I would suggest using a for
loop that iterates depending on how many times the user input. Let me know if you need more help!
GamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsGamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsHey Jon, I understand what you are saying. However, I just have a really hard time writing the code down for that matter, even though I know i need to use a loop that iterates depending on the entry of the user. Could you please give me some more help?
Thanks, GamingWithHan
Jon Wood
9,884 PointsJon Wood
9,884 PointsOf course! I reviewed the challenge and all you need to do is print out "Yay!" the number of times a user inputs. Check out this shell of code:
I left the body of the for loop blank and the
i <
blank so you can give it a shot. I do useTryParse
instead ofParse
to help handle invalid inputs but I don't think it's required in this challenge. Hope it helps, but let me know if you need more.GamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsGamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsThanks so much!
Jon Wood
9,884 PointsJon Wood
9,884 PointsAnytime! Glad it helped! :)