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 trialDejan Strancar
12,382 PointsThis code is passing in a separate wokspace
putting the code from step 3 in a separate wokspace, compiling and running it works just as intended and specified by the task. What am i missing here?
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
while(true){
Console.Write("Enter the number of times to print \"Yay!\": ");
try{
var entry = Console.ReadLine();
int count = Int32.Parse(entry);
if (Int32.TryParse(entry, out count)){
if (count <= 0){
Console.WriteLine("You must enter a positive number.");
continue;
}
while ( count > 0){
Console.WriteLine("Yay!");
count--;
}
}else{
continue;
}
}
catch(FormatException){
Console.WriteLine("You must enter a whole number.");
continue;
}
break;
}
}
}
}
1 Answer
Steven Parker
231,269 PointsBe careful about testing a challenge in a workspace or an external REPL.
If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.
In this case, it looks like you have an outer loop that will prevent the program from ending after it outputs an error message. According to the challenge instructions, the program should output "Yay!"s on a valid input, and output an error message on an invalid input, and either way it should end.