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

Java

Adam Bell
Adam Bell
1,176 Points

Output a sentence that takes both the noun and past tense verb using a single statement. It should look like this......

String name = console.readLine("Scorpion"); String pastTenseVerb = console.readLine("hated"); console.printf("%s really %s this coding exercise.", name, pastTenseVerb);

9 Answers

Kevin VanderWulp
Kevin VanderWulp
5,180 Points

console.readLine shouldn't take any parameters since this function does not output, but takes input from the user when it is run in the console.

String name = console.readLine(); 
String pastTenseVerb = console.readLine(); 
console.printf("%s really %s this coding exercise.", name, pastTenseVerb);
Alvaro Gutierrez
Alvaro Gutierrez
1,471 Points

Yeah Adam, Kevin is right. However, you want to also ask the user what to enter as a name. String name = console.readLine("Enter a name: ");

Adam Bell
Adam Bell
1,176 Points

Hey buddy I've GOT IT!!! I can't BELIEVE what I was doing wrong. smh

Kevin VanderWulp
Kevin VanderWulp
5,180 Points
System.out.print("Enter a noun: ");
String name = console.readLine(); 
System.out.print("Enter a past tense verb: ");
String pastTenseVerb = console.readline(); 
console.printf("%s really %s this coding exercise.", name, pastTenseVerb);

Try that. Like I said, the console.readLine() function shouldn't take any parameters, so there should be no text inside of the parenthesis of readLine().

Adam Bell
Adam Bell
1,176 Points

This is what I did. Not having any luck.

String name = console.readLine("name"); String pastTenseVerb = console.readline("Enter a past tense verb."); console.printf("%s really %s this coding exercise.", name, pastTenseVerb);

Adam Bell
Adam Bell
1,176 Points

Sorry, it's not working.

Kevin VanderWulp
Kevin VanderWulp
5,180 Points

I'm not sure what will work without being able to see what the challenge is asking for specifically.

Adam Bell
Adam Bell
1,176 Points

Okay. Here's the exact question. "Output a sentence that takes both the name and past tense verb using a single statement. It should look like this: name really past tense verb this coding exercise"

Adam Bell
Adam Bell
1,176 Points

{{{String name = console.readLine("Adam"); String pastTenseVerb = console.readLine("hates"); console.printf("%s really %s this coding exercise.", name, pastTenseVerb);}}};

Adam Bell
Adam Bell
1,176 Points

^^^That was the answer. I tried use markdown but I'm still getting the hang of all this. Thanks Kevin for your time and support.

yeah i'm having the same issue with the input below:

String name = console.readLine("Enter your name: "); String pastTenseVerb = console.readLine("Enter a past tense verb: "); console.printf(" $s really %s this coding exercise.", name, pastTenseVerb);

yeah i'm having the same issue with the input below:

String name = console.readLine("Enter your name: "); String pastTenseVerb = console.readLine("Enter a past tense verb: "); console.printf(" $s really %s this coding exercise.", name, pastTenseVerb);