Welcome to the Treehouse Community
Looking to learn something new?
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.
I got stuck. Can you guys please help me☺?
// I've imported java.io.Console for you. It is stored in a variable called console for you. String name = console.readLine("What is your name? "); String pastTenseVerb = console.readLine("Enter a verb here: "); console.printf("%s really %s this coding excercise", name, adjective);
Gaspar Santiago3,377 Points
If you were declaring the variable name, you wouldn't declare it with the sentence "What is your name?". You'd declare it with an actual name, which means in this case, "what is your name" should be on a separate line: System.out.println("What is your name?"); Declare the String variable name like so: String name = ""; < Leave it empty
Then when you run the program, console.readline() will take in whatever name you type in. The parameter for console.readLine() will be the String variable "name" which you will put in the parenthesis of console.readLine as its parameter. console.readLine(name); To check for this you can run: System.out.println("You entered " + name); Then the name you entered will be verified.
Apply the same logic for pastTenseVerb =D
Ryan Custodio5,626 Points
Hi. I'm just new here and I also got stuck on this but I manage to come up with the right answer.
String name = console.readLine("%s");
String pastTenseVerb = console.readLine("%s");
console.printf("%s really %s", name, pastTenseVerb);
I hope it helps.