ConsoleReader class

  • 5
  • Locked
Today students at the secret CodeGym center received a reading assignment. They (and you) need to create a ConsoleReader class with 4 static methods: one of them reads a string from the keyboard, the second — an integer, and the third — a fractional number. The fourth is different: it reads the string "true" or "false" from the keyboard and returns the corresponding boolean value.
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Karas Level 14 , Tampa, United States
2 September, 00:23
I present you three of my friends: Double.parseDouble(); Integer.parseInt(); Boolean.parseBoolean();
George Level 13 , United Kingdom
31 August, 14:54
I don't understand why it didn't let me create a static BufferedReader variable at the beginning of the class so all methods can reference it. Isn't that how you would do it to save memory/resources/time? Creating a new reader variable in every method seems a bit redundant.
Brandon Leirer Level 7 , Keller, United States
12 June, 19:21
Scanner made this much easier.
Thomas Level 9 , United States
9 December 2018, 16:19
I found this helpful for this task:
P. Puk Level 9 , Amsterdam, Netherlands
26 November 2018, 13:54
The assignment states to read a string(!) and return the boolean true or false. If I read a string and return true if the string is "true" or false if the string is "false" then I get the comment to read a boolean! So the assignment isn't clear...
Koushik Kintali Level 9 , Rayagada, India
20 October 2018, 09:54
How can we read a boolean value from keyboard
Roman Level 41
22 October 2018, 05:27
You can read the string "true" or "false" from the keyboard and convert it to the corresponding boolean value (true or false).
Kimberly Hughes Level 8 , San Antonio, United States
16 September 2019, 03:32
The question is how to do that.
Roman Level 41
31 October 2019, 07:54
Somehow like this:
String s = /*read string from console*/;
boolean b;
if ("true".equals(s)) {
  b = ...;
} ...