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 trialAndreas Sigsgaard
1,611 PointsTask will not pass despite code working as intended
The challenge will not let me pass this task, as it says that task 1 is no longer solved. Despite this the code is working great when i pull it all into workspaces and compile and run it myself. Can anybody help me to figure out why the challenge won't let me pass?
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
while (true){
Console.Write("Enter the number of times to print \"Yay!\": ");
var entry = Console.ReadLine();
var amountyay = 1;
if (entry.ToLower() == "quit")
{
break;
}
try
{
var entryInt = int.Parse(entry);
if (entryInt <=0){
Console.WriteLine("You must enter a positive number.");
continue;
}
while (amountyay <= entryInt)
{
Console.WriteLine("Yay ");
amountyay++;
}
}
catch(FormatException)
{
Console.WriteLine("You must enter a whole number");
}
}
}
}
}
1 Answer
Steven Parker
231,248 PointsBe careful about testing a challenge in an external REPL or IDE.
If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.
In this case, you have added an extra loop that prevents the program from ending until "quit" is entered..
A program that follows the challenge instructions will only ask for input one time, and either print "Yay!"s or an error message. But either way it should end.