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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Laurence Cimosz](https://secure.gravatar.com/avatar/a80b72104fc3f7c3cffa0c47aae7bb41?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Laurence Cimosz
8,993 Pointsthis is not the task, it's the work space prototype. why is the prototype not working
this is not the task, it's the code to the work space prototype. why is the prototype not working. how can I attach my work space code to a post? thank you
import java.io.Console;
public class TreeStory {
public static void main(String[] args) {
Console console = System.console();
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
int age = 12;
if (age < 13) {
//Insert exit code
console.printf("Sorry you must be at lest 13 to use this program.\n");
System.exit(0);
}
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ");
String verb = console.readLine("Enter a verb ending with -ing: ");
console.printf("Your TreeStory:\n--------------\n");
console.printf("%s is a %s %s. ", name, adjective, noun);
console.printf("They are always %s %s.\n", adverb, verb);
}
1 Answer
![Antonio De Rose](https://secure.gravatar.com/avatar/874005afcfec1528616a756435401c28?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Antonio De Rose
20,885 Pointscould you please try this, I do not have an answer why the console readLine, always gives an error, it does gives me too, but I am seeing it as an issue for so many, and the recommended class is scanner, try the below code, which I have shaped, as per to your requirement, and as per to fit into java terms, where there will be no errors
package com.example.java;
import java.text.NumberFormat;
import java.util.Locale;
import java.io.Console;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//Console console = System.console();
Scanner s = new Scanner(System.in);
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
int age = 16;
if (age < 13) {
//Insert exit code
System.out.println("Sorry you must be at lest 13 to use this program.\n");
System.exit(0);
}
System.out.println("Enter a name: ");
String name = s.nextLine();
System.out.println("Enter an adjective: ");
String adjective = s.nextLine();
System.out.println("Enter a noun: ");
String noun = s.nextLine();
System.out.println("Enter an adverb: ");
String adverb = s.nextLine();
System.out.println("Enter a verb ending with -ing: ");
String verb = s.nextLine();
System.out.println("Your TreeStory:\n--------------\n");
String result = String.format(name, adjective, noun, "\"%s is a %s %s. \", ");
String result1 = String.format("They are always %s %s.\n", adverb, verb);
System.out.println(result);
System.out.println(result1);
}
}