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) 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
231,248 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.