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

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
229,785 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.