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 trial
Christian Tisby9,329 Points
Final code challenge C# basics
I have gone through the entire C# basics course and have reached the final, and I"m stumped.
Here's the first part:
This final code challenge will require you to use almost everything we've covered in this course. You’ll write a program to celebrate completing this course by printing “Yay!” to the screen a given number of times. Write a program that: Prompts the user to enter the number of times to enter “Yay!”. I've done this for you. Leave this as it is. Prints “Yay!” to the screen that number of times (Hint: You’ll need a loop for this. You’ll also need to keep track of how many times the loop has run). You can print them all on the same line or on separate lines.
I don't even know where to start. In the meantime, I will be going over my notes and the videos again. Please help!
static void Main()
int runningTotal = 0;
bool keepGoing = true;
Console.Write("Enter the number of times to print \"Yay!\": ");
Jennifer NordellTreehouse Teacher
Hi there, Christian! The code you've posted thus far has 2 unused variables and one infinite loop. So, I'm going to post some steps to take here and we'll see if that helps. This will reflect my solution.
- Prompt the user for a number
- Read in the number from a user and assign the result to an int. You will need to parse this.
- Set up a
forloop to run from 0 to less than but not equal to the number given by the user
- Inside the
forloop print out "Yay!"
I hope this helps, but let me know if you're still stuck!