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#

Console I/O task 2/2 I can't see what's wrong with my answer.

The task is: Use the System.Console.ReadLine method to read the userโ€™s response from the console and store it in a variable named bookTitle.

And my answer is: string BookTitle = System.Console.ReadLine();

I can't see what I have done wrong.

4 Answers

andren
andren
28,558 Points

When you do challenges with multiple parts you have to keep the code from the previous parts in order to succeed. The first task in the Console I/O challenge asked you to use System.Console.Write to prompt a user for their favorite book, since you removed that code the challenge will fail even if your code passes the second task.

Additionally the variable name being asked for "bookTitle" and the one you used "BookTitle" are not the same.

When you do challenges most variable names has to match exactly with the names that the challenge asks for, and variable names like most things in programming are case sensitive.

So you need to add the solution to the first task back to your code and fix the capitalization of your variable name, so that it looks like this:

System.Console.Write("Enter a book title: ");
string bookTitle = System.Console.ReadLine();

Edit: This answer was edited to merge my original answer and my later comment down below together, due to the fact that my original answer on its own seems to have caused some confusion.

I have wrote bookTitle, and it says: Bummer! Are you calling the 'Write()' method as specified in the instructions?

andren
andren
28,558 Points

When you do challenges with multiple parts you have to keep the code from the previous parts in order to succeed, the first task in the Console I/O challenge asked you to use System.Console.Write to prompt a user for their favorite book, since you removed that code the challenge now fails even though your code passes the second task.

So you need to add the solution to the first task back to your code so that it looks like this:

System.Console.Write("Enter a book title: ");
string bookTitle = System.Console.ReadLine();
Brianna Ingram
Brianna Ingram
642 Points

I understand up until this point, but I am having trouble with the next task: "Use the System.Console.ReadLine method to read the userโ€™s response from the console and store it in a variable named bookTitle." My only clue is : "Enter a book title.".

Thank you very much :)

steeve Francois
PLUS
steeve Francois
Courses Plus Student 572 Points

I do not understand I tried what andren said is the answer it did not work

Edward CINTRON
Edward CINTRON
5,254 Points

didn't work with 'string', used 'var' instead and it worked