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 trialKasper Delfs
802 PointsStuck with final challenge
I am asked to write a piece of code that prints "yay!" the amount of times the user enters. Furthermore I need to keep track of how many times the loop runs.
I have this code as my starting point but i'm not sure how to aproach it.
using System;
namespace Treehouse.CodeChallenges { class Program { static void Main() { Console.Write("Enter the number of times to print \"Yay!\": ");
}
}
}
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ");
}
}
}
1 Answer
Steven Parker
231,269 PointsThere's a few steps to this task:
- create a variable for counting in a loop
- do something to input the user's answer to the question (perhaps using ReadLine)
- convert the answer into a number and store it to use as a counter (maybe using int.Parse)
- create a loop to repeat the number of times given.
- inside this loop, write out the string "Yay!".
Once you get past task 1, here are a few more hints for passing task 2.