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#

Steven Parker
Steven Parker
231,210 Points

Hints for C# Basics, Final Challenge, Task 2 of 2

Not a question, but hints in hopes that people will find it when they have a problem instead of creating their own very specific question (yet again).

*I'm creating this generic question in hopes that people will find it when they have a problem instead of creating their own very specific one (yet again).*The challenge asks: Add more input validation to the program by printing "You must enter a positive number." if the user enters a negative number.

You're sure you have a good answer, and perhaps have even tried building it elsewhere to test it, but it won't compile in the challenge and/or does not pass. What's wrong?

I'm creating this generic question in hopes that people will find it when they have a problem instead of creating their own very specific one (yet again).

2 Answers

Steven Parker
Steven Parker
231,210 Points

People often over-think this one and get too creative, and their answer is rejected for a variety of reasons (some which don't seem to make any sense).

Here are the secret "rules" you must follow for success on this one:

  • Your program must ask for and accept input ONE TIME ONLY
  • If the input validates, your program will print some "Yay!" messages and exit
  • If the input does not validate, it will print the error message and exit
  • Either way, it will exit
John Lukacs
John Lukacs
26,806 Points

I've tried all day to solve this is there any chance you can just give me the code