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

AYODELE OWOLABI
AYODELE OWOLABI
639 Points

Task 1 is no longer passing.

I have been having this problem for 2 weeks now. After completing the first task and attempting the second one, I get an error "Task 1 is no longer passing". Please help fix

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {
            int i = 0;
            Console.Write("Enter the number of times to print \"Yay!\": ");
            string input = Console.ReadLine();
            try
            {
            int count = int.Parse(input);
               if(i < count)
               {
                Console.WriteLine("You must enter a positive number");
               }
               else
               {
               i = i + 1;
               Console.WriteLine("Yay!");

               }
            }
            catch(FormatException)
            {
                Console.WriteLine("You must enter a whole number");
            }
        }
    }
}

1 Answer

Steven Parker
Steven Parker
218,679 Points

It looks like you removed the originally provided "while" loop while adding the task 2 code. That loop is necessary for both tasks.

Also, take another look at the test for negative input. Instead of comparing the index to the count, you probably want to compare the count with 0.

AYODELE OWOLABI
AYODELE OWOLABI
639 Points

Thanks. I was able to resolve it.