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 trial

C# C# Basics (Retired) Perfect Final

Dan Comperini
PLUS
Dan Comperini
Courses Plus Student 2,215 Points

Oops! It looks like Task 1 is no longer passing.

All three code challenges work, why am I getting this error?

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {

            while (true)
            {
                var x = 0;
                var times = 0;

                Console.Write("Enter the number of times to print \"Yay!\": ");
                var input = Console.ReadLine();

                try
                {
                    times = int.Parse(input);
                    if (times < 0);
                    {
                       Console.WriteLine("You must enter a whole number.");
                       break;
                    }
                    while (x < times)
                    {
                        Console.WriteLine("Yay!");
                        x++;
                    }
                    break;
                }
                catch (FormatException)
                {
                    Console.WriteLine("You must enter a whole number.");
                    break;
                }
            }


        }
    }
}

1 Answer

Dan Comperini
PLUS
Dan Comperini
Courses Plus Student 2,215 Points

I found the issue. I had to copy my final code answer to each challenge.