Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Christian Tisby
9,329 PointsFinal 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!
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
int runningTotal = 0;
bool keepGoing = true;
While (true)
{
Console.Write("Enter the number of times to print \"Yay!\": ");
}
}
}
}
2 Answers

Jennifer Nordell
Treehouse TeacherHi 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
for
loop to run from 0 to less than but not equal to the number given by the user - Inside the
for
loop print out "Yay!"
I hope this helps, but let me know if you're still stuck!

John Pellow
16,427 Pointswow, very fast response and excellent job. thank you kindly, Jennifer.
John Pellow
16,427 PointsJohn Pellow
16,427 PointsSo use a for loop, when we haven't learnt for loop yet? so go elsewhere to learn to code?
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherSorry about that, Christian. You're correct. The concept of a
for
loop doesn't seem to have been introduced yet. You are not required to use one, it's just how I did it. I've taken quite a number of courses here at Treehouse and it's hard to keep track of when something is introduced, so please excuse my recommendation of a for loop.This is how I did it with a regular
while
loop.Again, I apologize for the confusion. Please bear in mind that moderators are not Treehouse staff. When you post here, you are, for the most part, addressing other students. I'm a student just like you are!
I hope this helps!
Steven Parker
220,513 PointsSteven Parker
220,513 PointsIf you continue learning C#, you'll learn about For Loops in the C# Objects course.