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#

Thomas Newton
PLUS
Thomas Newton
Courses Plus Student 2,442 Points

Not sure what I've done wrong.

I have been following the tutorial almost exactly, yet when I try to compile the file I get two errors I can't divine the cause of. Can anyone point me in the right direction here?

This is my code:

using System;

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

    while (keepGoing)
    {
        // promt the user for minutes exercised
      Console.Write("How many minutes have you exercised? Type \"Quit\" to Exit: ");

      string entry = Console.ReadLine();

      if (entry == "Quit");
      {
        keepGoing = false;
      }
        else
        {
        int minutes = int.Parse(entry);

        if(minutes <= 0)
        {
          Console.WriteLine(minutes + " is not a valid entry. Get to work, slacker!");
          continue;
        }

        else if(minutes <= 10)
        {
          Console.WriteLine("Well... it's a start, at least!");
        }
        else if(mintues <= 30)
        {
          Console.WriteLine("Nice work! Keep up the momentum!");
        }
        else if (mintues <= 60)
        {
          Console.WriteLine("Well done! You're doing great!");
        }
        else
        {
          Console.WriteLine("Whoa, maybe you should take a break!");
        }

        // add minutes exercised to total
       runningTotal = runningTotal + minutes;

        // display total minutes exercised
      Console.WriteLine("You've exercised " + runningTotal + " minutes!");
      }
        // repeat until the user quits
    }

    Console.WriteLine("Goodbye!");
  }

} }

And the errors I have been getting are:

Program.cs(20,11): warning CS0642: Possible mistaken empty statement
Program.cs(23,10): error CS1525: Unexpected symbol else' Program.cs(52,246): error CS1525: Unexpected symbolend-of-file'
Compilation failed: 2 error(s), 1 warnings

2 Answers

anil rahman
anil rahman
7,786 Points

To fix the next is errors is:

else
        {
        int minutes = int.Parse(entry); //change this declaration into just an initalizing step

So at the very top make minutes a variable declaration at top of main, accessible multiple places.

 class Program { 

static void Main() {
int minutes;


..}

Then change the previous else line to this:

else
        {
        minutes = int.Parse(entry); //change this declaration into just an initalizing step

Also at two else if blocks in the conditions you spelt minutes wrong.

else if(mintues <= 30) //<--here
        {
          Console.WriteLine("Nice work! Keep up the momentum!");
        }
        else if (mintues <= 60) //<--here
anil rahman
anil rahman
7,786 Points
//here is the error the ; at the end
 if (entry == "Quit"); <--