Census

  • 10
People and other citizens of the universe quite often try to find their relatives. Let's take a step towards a program that can search for people. In this task, we need to create a dictionary (Map), add ten (last name, first name) entries, and then check how many people have the same first name or last name.
You can't complete this task, because you're not signed in.
Comments(26)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
IvanPLevel 13 , Barcelona
6 May, 03:45
care with the order haha
16 April, 16:40
Interesting point on this task let's say you give everyone a different last name e.g. Smith1, Smith2, Smith3, Smith4, etc...each key unique as required. BUT you give everyone the exact same first name e.g. all values = John. You will find that your total numbers for last name will be 10 and firstname 100. My code passed with this, I know this isn't correct since there are not 100 "John" in first name, but we do pass "John" into the first name function 10 times.
Kent HerveyLevel 13
31 December 2019, 04:46
My clues to help clarify confusion on instructions: yes, (last name, first name) really does mean what you think: key, value And yes, Map does not allow duplicate keys, so yes the return on last name will be either 0 or 1. First Name should not be confusing at all. Instructions are clear.
Mansoor MujawarLevel 23 , El Paso
11 December 2019, 14:29
please read it properly requirement is (last name, first name) pairs. hence last name is key, and first name is value.
Kent HerveyLevel 13
31 December 2019, 02:44
But then what does this mean: Check how many people have the same first name or last name.
Stanislav MayerLevel 8 , Brno
10 December 2019, 10:34
Disappointing task if you ask me. It took me like 60 minutes to resolve it, from which 45 minutes I needed to understand what they actually want from me. If you are in doubt like me, then understand that they want you to use map's KEY for last names and map's VALUE for names and then compare them to name/lastName parameter, as described by PaFi in the previous comment.
PaFiLevel 16
22 November 2019, 12:12
Last 2 requirements should be 4. The getSameFirstNameCount() method must return the number of people that have the same first name as the value of the name parameter. 5. The getSameLastNameCount() method must return the number of people that have the same last name as the value of the lastName parameter.
Tomasz EnyeartLevel 13 , Santa Rosa
23 November 2019, 03:30
thank you, i came here to ask if that what the last 2 requirements wanted
TonatiuhLevel 12 , Mexico
6 December 2019, 22:39
Thanks, I was confused at the beginning. The point here is to realize that we need to compare the name parameter inside the getSameFirstNameCount() method and the lastName parameter inside the getSameLastNameCount() method.
VrhLevel 9 , Zagreb
14 July 2019, 11:59
Damn, lost a lot of time on this assignment... The error was I didn't read the assignment properly so I was putting first name in keys and last name in values.
Kent HerveyLevel 13
31 December 2019, 02:33
That was my thinking too, so I cam here to figure out what it really means....since HashMap does not even allow duplicate keys
KIN SOCHEATLevel 25 , Phnom Penh
12 June 2019, 06:38
oh..sorry
KIN SOCHEATLevel 25 , Phnom Penh
12 June 2019, 03:42
/* Comment has been deleted */
RomanLevel 41
12 June 2019, 05:35
Posting the solution in the comments is prohibited.
TejLevel 9 , Hyderabad
18 November 2019, 21:39
Please help me out https://codegym.cc/tasks/com.codegym.task.task08.task0815
RomanLevel 41
19 November 2019, 07:25
Please refer to Help section at our course.
Keith EmeryLevel 17 , Saint Louis
9 June 2019, 05:25
If you are just starting this exercise, recognize from the beginning that HashMaps must have unique keys. So despite the ambiguity of the instructions, you are not to provide duplicate last names and then try to deal with them in your program.