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) Perform if / else

Christian Poppe
Christian Poppe
290 Points

Program.cs(33,16): error CS0136

This comes up, and does not change even when I change the string 'entry' to something like 'item'.

Christian Poppe
Christian Poppe
290 Points

Program.cs(33,16): error CS0136: A local variable named entry' cannot b e declared in this scope because it would give a different meaning toe ntry', which is already used in a child' scope to denote something else Program.cs(36,13): error CS0136: A local variable namedminutes' cannot be declared in this scope because it would give a different meaning to minutes', which is already used in achild' scope to denote something else

Christian Poppe
Christian Poppe
290 Points

using System;

namespace Treehouse.FitnessFrog {

class Program { static void Main() { int runningTotal = 0;

    bool keepGoing = true;   
    while (keepGoing)
    {
         // Prompt the user for minutes exercised
      Console.Write("Enter how many minutes you exercised: ");     
      string entry = Console.ReadLine();

      // 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 the user quits

    }

    // Prompt the user for minutes exercised
    Console.Write("Enter how many minutes you exercised: ");     
    string entry = Console.ReadLine();

    // 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 the user quits
  }

} }

1 Answer

Steven Parker
Steven Parker
210,130 Points

It looks like the code in the loop somehow got duplicated again after the loop. Get rid of the duplicated code and that should fix the issue.

But you'll also need some additional code inside the loop to change the value of "keepGoing" so the program can end when the user wants to quit.