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 trialJonas Olsen
1,081 PointsBummer! Try again!
I'm just getting the Bummer! Try again! and i can not figure out what is wrong with my code.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
while(true)
{
Console.WriteLine("Enter the number of times to print \"Yay!\": ");
string entered = Console.ReadLine();
// Console.WriteLine("You entered: " + entered);
try
{
if (entered == null) {
continue;
}
double countingTo = int.Parse(entered);
if(countingTo < 1 )
{
Console.WriteLine("You must enter a whole number.");
continue;
}
for(int i = 0;i < countingTo;i++)
{
Console.WriteLine("Yay!");
}
break;
}
catch(FormatException)
{
Console.WriteLine("You must enter a whole number.");
continue;
}
catch(OverflowException)
{
Console.WriteLine("You must enter a whole number.");
continue;
}
}
}
}
}
1 Answer
Steven Parker
231,248 PointsYour program works differently from the instructions.
In this case, you have added an extra loop that prevents the program from ending if bad values are 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.
Jonas Olsen
1,081 PointsJonas Olsen
1,081 PointsThank you for the help, i finished the challenge after removing the extra loop!