New user

Report a typo

A beginner programmer is a site administrator. He has a map where for each user there is a key (the login) and a value (the password). Now he needs to add the data of a new user. Write a function addUser that takes a map with user data userMap, a login, and a password and adds the latter two to userMap.

If userMap already contains a user with such a login, firstly print the following string: "User with this login is already registered!". After that, output the userMap without changes.

Input: userMap: Map<String, String>, login: String, password: String

Output: updated userMap: MutableMap<String, String>

Sample Input 1:

new_login
new_password

Sample Output 1:

{[email protected]=qwerty123, [email protected]=abcdef00, [email protected]=000000, new_login=new_password}

Sample Input 2:

Sample Output 2:

User with this login is already registered!
{[email protected]=qwerty123, [email protected]=abcdef00, [email protected]=000000}
Write a program in Kotlin
fun addUser(userMap: Map<String, String>, login: String, password: String): MutableMap<String, String> {
// write your code here

}
___

Create a free account to access the full topic