1. Enter a few strings (keys) from the keyboard [in a loop].
The following strings (keys) are allowed: "user", "loser", "coder", "programmer".
Stop reading in strings after reading in any string that does not match one of the above.
2. For each entered string:
2.1. Create the appropriate object [see Person.java], e.g.
User, loser, coder and programmer
- 16
Locked
Comments (12)
- Popular
- New
- Old
You must be signed in to leave a comment
Hoist
5 March, 04:31
That took a year; ... finally ... started over and READ many HELP examples line x line to understand this
I usually just live.
I usually do nothing.
I usually write code.
It's a wonderful life!
user
loser
coder
programmer
person
![]()

0
Vadim “迪姆哥”
6 December 2022, 13:04
Why code with correct output isn't pass verification?
I compared my code with correct solution, found that it does the same but in different way, with fewer checks.
Did logic of my code had any issues or vulnerabilities?
https://codegym.cc/help/17404
0
Justin Smith
9 August 2021, 17:35
This is the first time we have had a task where we get more input after the system outputs something. So a lot of people might assume that the task wants you to get all the readLines before printing anything. The task conditions also seem to suggest that, unfortunately. The structure they've set up in the pre-existing code paints a different picture, though. You should read a line, let the system output the appropriate response, read a line, output response, etc.
0
Karas Java Developer
2 March 2021, 23:33
Okay, this is definitelly something I did not expected but now looking back it makes sense,
Type casting has to be used in order to call the methods. Because the Person class has no methods if you just call it in the passed object it will not work as it is a Person, you have to shrink it.
0
Oliver Heintz
8 December 2020, 02:17
Another task where I felt like the code I wrote initially did the job that was asked and should have passed verification, but didn't, so I had to go back and look at nuances. Initially I wrote so that you entered all the strings until you entered one that wasn't accepted, and then the program spat out all the output and ended in one go. Apparently the program is meant to spit out the output as you enter the strings. It's these little things that are so frustrating.
0
Justin Smith
9 August 2021, 17:36
Not your fault for thinking that, the task conditions, as written, make it seem like that's what they want.
0
Petros
6 August 2020, 17:19
The ONLY reason this is hard is because the verification is messed up. In the main method, when I switched from if else to a switch statement, suddenly my answer was accepted. Please fix the verification for this problem. It had me almost pulling hair.
0
Roman
7 August 2020, 05:46
My answer with if-else was accepted. I think, you have other error.
+2
Lucas Hoage
13 June 2020, 00:15
Good exercise.
0
null
9 May 2020, 18:12
There is an error for checking the condition. If Im using if(reader.readLine().equals(" ")); It won't pass. Instead using key = reader.readLine(); then if(key.equals(" ")), will work. So I think the checking condition should be more flexible about this.
0
Andreas Dengler
29 April 2020, 03:03
I program on my phone in the app and when I create a file and go out of the task and back in ALL classes also the Solution class is gone and deleted. I cant solve the task like that please help!
0
Learner
15 October 2018, 06:49
Line no: 16 You read first line of input.
Line no: 26 If the input IS user / loser/ coder / programmer then command goes to else block.
Line no: 30 You read another line of input in 'key'
So, you are skipping first line of input completely.
So, if I give input as
user
exit
then, Line 16: s = user
Line 26 - else block
Line 30 key = exit
Here, user did not get processed.
0