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 Receiving Input

Bikram Perhar
Bikram Perhar
163 Points

https://w.trhou.se/wp7153p386 why when i enter 30 it says bash: 30: command not found

why when i enter 30 it says

8 Answers

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Bikram, the problem appears to be that your code is missing a semi colon, preventing your program from compiling. Hence you are not actually running your program, and instead are typing 30 into the terminal, which isn't a valid command.

System.Console.Write("Enter how many minutes you exercised: ") // missing semi colon
treehouse:~/workspace$ mcs Program.cs                                                  
Program.cs(10,9): error CS1525: Unexpected symbol `string'                                                                                   

In order to run your program you must perform the following steps:

  1. Compile the code by writing in the terminal: mcs Program.cs
  2. Run the program by writing into the terminal: mono Program.exe

Umesh Ravji - +1 for a solid catch. I missed it at first glance. Adding the semi-colon and recompiling the code allowed the program to run through a single cycle as expected with the existing code.

Umesh Ravji
Umesh Ravji
42,386 Points

Actually your answer was something I never considered and your right, the existing Program.exe simply printed the message to the console and finished running.

Umesh Ravji - Honestly, after I read your answer and saw the missing semi-colon and your error report, I was rather surprised that it had compiled in the first place. Your answer was more accurate than mine, as fixing that issue also resolved the program to wait for input before closing. I hadn't considered it would be something like the semi-colon because the program actually had compiled enough to run when I tried to run it.

Bikram Perhar
Bikram Perhar
163 Points

still don't understand where am i missing the semi colon and when i put

// Prompt user for minutes exercised System.Console.Write("Enter how many minutes you exercised; ")

Where do i add it?

the semi colon is after the last bracket?

Bikram Perhar
Bikram Perhar
163 Points

where do i miss the semi colon

Umesh Ravji
Umesh Ravji
42,386 Points

On this line..

System.Console.Write("Enter how many minutes you exercised: ") 
Bikram Perhar
Bikram Perhar
163 Points

i put it in exactly as u type above

Umesh Ravji
Umesh Ravji
42,386 Points
System.Console.Write("Enter how many minutes you exercised: "); // <-- semi colon goes right at the end :)
Nathanial Harmon
Nathanial Harmon
505 Points

semi colon to finish the line. yes after the bracket

Bikram Perhar
Bikram Perhar
163 Points

System.Console.Write("Enter how many minutes you exercised: ") I put it in exactly like you typed

Bikram Perhar
Bikram Perhar
163 Points

like this System.Console.Write("Enter how many minutes you exercised: ");

I feel so dumb

Umesh Ravji
Umesh Ravji
42,386 Points

Just like that. Don't feel dumb, just learn from your mistakes :)

Bikram Perhar
Bikram Perhar
163 Points

ok then i go mono Program.exe? Then what?

You first need to recompile the code after you added the missing semicolon. You can figure out how to do that by rewatching this or just glancing at the teacher notes on the video. Once it compiles properly, you should be able to run the program by typing what you just did into the Workspaces terminal. If you haven't changed anything but the semicolon since I looked at your code last, it will run fine and ask for how long you exercised, waiting for input, then it will close out once you provide the input (since you hadn't built the loop and exit functionality at that time).

Bikram Perhar
Bikram Perhar
163 Points

i watched the video then did this

To compile: mcs Program.cs

To run: mono Program.exe

still getting an error when i do the first one then when i do the second 1 and add enter still says bash 30 not found

https://w.trhou.se/7y1h1cn47w

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Bikram, you have a colon, instead of a semi-colon at the end of the line I have mentioned below. Are you not getting that error when you are compiling your code? Since the code is not compiling properly, you are running an older version of Program.exe (which I recommend you just delete).

treehouse:~/workspace$ mcs Program.cs                                                                           
Program.cs(10,42): error CS1525: Unexpected symbol `:', expecting `,' or `;'                                    
Compilation failed: 1 error(s), 0 warnings 
string entry = System.Console.ReadLine(); // you have a : instead of ;
Bikram Perhar
Bikram Perhar
163 Points

I'm getting so frustrated I don't think I'm smart enough to to learn. I have so many ideas for apps but rather make them myself instead of paying someone to.