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
171,342 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.