C# C# Basics (Retired) Perform if / else

broken?

sooo i was doing the exact steps. I ran it and it said everything it should, except when i put in the minutes the program stops working it just ends and puts the console back to the starting state. so I got desperate and copied the teacher's notes code. It was very annoying to see that THE SAME THING HAPPENED. nothing had changed. it didn't repeat, nothing. is this a bug? please help. the code is below ( it is the teachers notes) using System;

namespace Treehouse.FitnessFrog { class Program { static void Main() { int runningTotal = 0;

        bool keepGoing = true;
        while(keepGoing)
        {
            // Prompt user for minutes exercised 
            Console.Write("Enter how many minutes you exercised or type \"quit\" to exit: ");
            string entry = Console.ReadLine();        

            if(entry == "quit")
            {
                keepGoing = false;
            }
            else
            {
                // Add minutes exercised to total 
                int minutes = int.Parse(entry);
                runningTotal = runningTotal + minutes;

                // Display total minutes exercised to the screen 
                Console.WriteLine("You've entered " + runningTotal + " minutes.");
            }
            // Repeat until user quits
        }

        Console.WriteLine("Goodbye");
    }
}

}

never mind it was the input. thank you so much!

1 Answer

Jon Wood
Jon Wood
9,883 Points

I ran the same code you posted and it seems to work fine. What input are you giving it?