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 trialCharles Hessifer
Courses Plus Student 11,866 PointsC# Basics - Challenge Task 2 of 3 - What am I missing?
For some reason my code is not passing; however I can compile run on my local dev box. Could someone have a look and see what I might be missing please? (Code Attached)
Thanks in advance!
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
var counter = 0;
while (true)
{
Console.Write("Enter the number of times to print \"Yay!\": ");
try
{
var printCount = int.Parse(Console.ReadLine());
while (counter < printCount)
{
Console.WriteLine("Yay!");
counter += 1;
}
break;
}
catch (FormatException)
{
Console.WriteLine("You must enter a whole number.");
continue;
}
catch (ArgumentNullException)
{
continue;
}
}
}
}
}
1 Answer
Charles Hessifer
Courses Plus Student 11,866 PointsThanks Steven!
Your program must ask for and accept input ONE TIME ONLY, s/continue/return/g
CaH
Charles Hessifer
Courses Plus Student 11,866 PointsCharles Hessifer
Courses Plus Student 11,866 Pointstried with for loop as well: