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

Michael Russell
Michael Russell
7,332 Points

Cannot submit final challenge because of error

Hello, I cannot preview or check work for my final challenge because when I do, I keep receiving the following error:

Oh no! There was a temporary issue running this code challenge. We've been notified and will investigate the problem.

If you continue experiencing problems, please contact support at help@teamtreehouse.com.

Fear not! Your code is safe with us. You will be able to resubmit once you reload the challenge.

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        private const string yay = "Yay!";
        static void Main()
        {
            Console.Write("Enter the number of times to print \"Yay!\": ");

            //Get user input
            string userInput = Console.ReadLine();

            //Parse input to integer
            int numberOfTimes = int.Parse(userInput);

            //Counter variable to identify how many times the loop has ran
            int counter = 0;


          //Print to screen
            while (numberOfTimes > 0)
            {
                Console.WriteLine(yay);
                counter ++;
            }



        }
    }
}

3 Answers

Steven Parker
Steven Parker
231,084 Points

That error is often caused by a program that contains an infinite loop, which is exactly the case here.

Your loop condition is testing the value of "numberOfTimes", but that variable does not get changed inside the loop, so the condition will never be different. I see that the value of "counter" does change in the loop, so perhaps you meant to include it as part of the loop condition.

you need to use IF and IF ELSE statement also..

Steven Parker
Steven Parker
231,084 Points

Why would you need an "if" statement once the loop condition was corrected?

I have completed the challenge and to fulfill the condition; conditional statement is needed. e.g. what if the number is less than or equal to zero?

Steven Parker
Steven Parker
231,084 Points

Oh, you're thinking of a different task of this challenge. Michael is clearly still working on task 1.