User, loser, coder and programmer

  • 16
  • Locked
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], e.g.
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Justin Smith
Level 31 , Greenfield, USA, United States
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.
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.
Oliver Heintz
Level 18 , Mustang, United States
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.
Justin Smith
Level 31 , Greenfield, USA, United States
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.
Level 23 , Columbia, United States
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.
Level 41
7 August 2020, 05:46
My answer with if-else was accepted. I think, you have other error.
Lucas Hoage
Level 14 , Savannah, United States
13 June 2020, 00:15
Good exercise.
Level 26 , Orlando, United States
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.
Andreas Dengler
Level 16 , Bielefeld, Deutschland
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!
Level 16 , India
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.