Usernames An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below: Username MUST contain at least 6 characters; Username cannot start with a number; Username can only contain letters or numbers. If valid, the username may be resgistered if it doesn't already exist in the system. You should not use built-in functions to determine the character type such as isnumeric() or islower(). Use the strings given alphabet and numeric to determine if each character is valid. Use the list registered to help you determine if the username is already registered. Don't forget to execute the cell below to use these strings # run this cell to create these variables alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' numeric = "0123456789" registered = ["john87", "topmage", "light4ever", "username2"]   Write a function registerName which receives a String username and it returns a string message. This function: has username String argument: the desired username returns a message depending on whether the username is valid and available for registration Other notes: Use the function nameValidation implemented in Task 2 to check if the username is valid or not. If valid, check whether the username already exist in the registered list If it doesn't exist yet, return the message "Username registered successfully." If it exists, return the message "Sorry, this username is already taken." For invalid, return the message "The username is not valid.". Document your code using comments. Write at least 3 test cases to demonstrate your function's expected behaviour.   # your solution     # test cases print(registerName("ARYA STARK")) #expected output "The username is not valid." print(registerName("Teo Me+")) #expected output "The username is not valid." print(registerName("SAUL")) #expected output "The username is not valid." print(registerName("Galadr1EL")) #expected output "Username registered successfully." print(registerName("john87")) #expected output "Sorry, this username is already taken."   #your test cases(3 test cases)

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question

Usernames

An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below:

  1. Username MUST contain at least 6 characters;
  2. Username cannot start with a number;
  3. Username can only contain letters or numbers.

If valid, the username may be resgistered if it doesn't already exist in the system.

  • You should not use built-in functions to determine the character type such as isnumeric() or islower().
    • Use the strings given alphabet and numeric to determine if each character is valid.
  • Use the list registered to help you determine if the username is already registered.

Don't forget to execute the cell below to use these strings

# run this cell to create these variables
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
numeric = "0123456789"
registered = ["john87", "topmage", "light4ever", "username2"]

 

Write a function registerName which receives a String username and it returns a string message. This function:

  • has username String argument: the desired username
  • returns a message depending on whether the username is valid and available for registration

Other notes:

  • Use the function nameValidation implemented in Task 2 to check if the username is valid or not.
    • If valid, check whether the username already exist in the registered list
      • If it doesn't exist yet, return the message "Username registered successfully."
      • If it exists, return the message "Sorry, this username is already taken."
    • For invalid, return the message "The username is not valid.".
  • Document your code using comments.
  • Write at least 3 test cases to demonstrate your function's expected behaviour.

 

# your solution

 

 

# test cases
print(registerName("ARYA STARK")) #expected output "The username is not valid."
print(registerName("Teo Me+")) #expected output "The username is not valid."
print(registerName("SAUL")) #expected output "The username is not valid."
print(registerName("Galadr1EL")) #expected output "Username registered successfully."
print(registerName("john87")) #expected output "Sorry, this username is already taken."

 

#your test cases(3 test cases)

 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT