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

Pierce Knight
Pierce Knight
446 Points

Task are no longer passing, but going back to that task let's me proceed without changing anything

I've ran the code in terminal and all the steps work, but after task 3 of 3 it makes me go back to the first.

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {

        static void Main()
        {
            while (true)
            {
            int scope = 0;
            Console.Write ("Enter the number of times to print \"Yay!\": ");
            var number = Console.ReadLine ();
            try
            {
                scope = Int32.Parse(number);
                if (scope < 0)
                {
                    Console.WriteLine ("You must enter a positive number");
                }
            }
            catch (FormatException)
            {
                Console.WriteLine ("You must enter in a whole number");
            }


            while (scope > 0) 
            {
                Console.Write ("Yay!");
                scope = scope - 1;
            }
        }
    }
}
}

1 Answer

Steven Parker
Steven Parker
231,096 Points

You have an outer loop that prevents the program from ending.

A program built according to the instructions will prompt and accept input one time, and based on the input it will either print "Yay!"s or an error mesage. Either way, it should end. With the extra loop it never ends.