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) Console I/O Formatting Output

JONATHAN SALEM
JONATHAN SALEM
495 Points

Good Day Code Masters, I already copy and paste the code from the code written below, but still I got this errors. Pleas

Enter how many minutes you exercised: 30
treehouse:~/workspace$ mcs Program.cs
Program.cs(3,5): error CS1514: Unexpected symbol class', expecting.' or {' Compilation failed: 1 error(s), 0 warnings treehouse:~/workspace$ ^C treehouse:~/workspace$ mcs Program.cs Program.cs(3,5): error CS1514: Unexpected symbolclass', expecting .' or{'
Compilation failed: 1 error(s), 0 warnings
treehouse:~/workspace$

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! This will be infinitely easier to help you troubleshoot if we can see a snapshot of your workspace. On the upper righthand side of your workspace you should see a camera icon. Clicking this will allow you to create a "snapshot". If you link that here, we can fork your workspace and take a look around and help you narrow down the problem (or potentially even solve it!). :sparkles:

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, but you have a few issues going on here. The first one, and the one which is causing your compiler error is that your class must be defined inside the namespace. The namespace itself should have an open and closed curly brace. It's why it encountered an "unexpected class". It's because you didn't precede it with an open curly brace. Secondly, you should be using System; which is missing entirely from your workspace. Third, you have a capitalization error in the declaration of your string entry. It should be String instead of string. Remember that just about everything in programming is case-sensitive.

Here is my resulting code after I correct your code with some comments:

using System;  // This is required to use the Console functions

namespace Treehouse.FitnessFrog
{  //Note the open curly brace here

  class Program
  {
    static void Main()
    {
      // Prompt the user for minutes exercised
      System.Console.Write("Enter how many minutes you exercised: ");

      String entry = System.Console.ReadLine();  //Note the capitalisation of String
      // Add minutes exercised to total
      // Display total minutes exercised to the screen
      Console.WriteLine("You've entered " + entry + " minutes");

      // Repeat until the user quits

      Console.ReadLine();

    }
  }
} // Closed curly brace for the namespace

Hope this is helpful! Good luck and hang in there! :sparkles:

JONATHAN SALEM
JONATHAN SALEM
495 Points

Thank you soo much Ma'am Jennifer! it helped me a lot ... more power!

JONATHAN SALEM
JONATHAN SALEM
495 Points

Thank you for your quick response Ma'am Jennifer Nordell, I already took a snapshot and this link has opened https://w.trhou.se/hmywccqdr3 ... please help me,,, more power!