Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.