Site icon Tutor Bin

UMBC Username and Password Validator Program Project

UMBC Username and Password Validator Program Project

Description

You have been asked to write a username validation program for a small website. The website has specific rules on what constitutes a valid username, including:

  • All usernames must be between 8 and 15 characters long
  • Usernames can only contain alphabetic (a-z and A-Z) and numeric characters (0-9) – no special characters or spaces are allowed.
  • The first and last characters in a username cannot be a digit
  • Usernames must contain at least one uppercase character
  • Usernames must contain at least one lowercase character
  • Usernames must contain at least one numeric character

Write a program that asks the user to enter in a username and then examines that username to make sure it complies with the rules above. Here’s a sample running of the program – note that you want to keep prompting the user until they supply you with a valid username. User input is underlined:

Enter a username: foobar
* Length of username: 6
  ERROR - username must be between 8 and 15 characters long
* All characters are alphabetic or numeric: True
* First character is a digit: False
* Last character is a digit: False
* # of uppercase characters: 0
  ERROR - username must contain at least one uppercase character
* # of lowercase characters: 6
* # of digit characters: 0
  ERROR - username must contain at least one digit character
Username is not valid, please try again

Enter a username: FOOBAR5
* Length of username: 7
  ERROR - username must be between 8 and 15 characters long
* All characters are alphabetic or numeric: True
* First character is a digit: False
* Last character is a digit: True
  ERROR - last character cannot be a digit
* # of uppercase characters: 6
* # of lowercase characters: 0
  ERROR - username must contain at least one lowercase character
* # of digit characters: 1
Username is not valid, please try again

Enter a username: FooBar5
* Length of username: 7
  ERROR - username must be between 8 and 15 characters long
* All characters are alphabetic or numeric: True
* First character is a digit: False
* Last character is a digit: True
  ERROR - last character cannot be a digit
* # of uppercase characters: 2
* # of lowercase characters: 4
* # of digit characters: 1
Username is not valid, please try again

Enter a username: FooFooFoo
* Length of username: 9
* All characters are alphabetic or numeric: True
* First character is a digit: False
* Last character is a digit: False
* # of uppercase characters: 3
* # of lowercase characters: 6
* # of digit characters: 0
  ERROR - username must contain at least one digit character
Username is not valid, please try again

Enter a username: Foo999Bar
* Length of username: 9
* All characters are alphabetic or numeric: True
* First character is a digit: False
* Last character is a digit: False
* # of uppercase characters: 2
* # of lowercase characters: 4
* # of digit characters: 3
Username is valid!

Hint: you will need to count the # of uppercase, lowercase and digit characters using some kind of loop.

Part 1a is an intermediate step towards the final version of this program. You do not need to turn in this part of the program – keep working and turn in part 1b when you are finished. You only need to turn in part 1b.

Part 1b: Password Validator

This is a solo project. You may start working in your Ed workspace as a group to help each other out, but after class everyone should download any work written by the group and continue working locally on their own computer. You will be doing yourself a HUGE disservice by not working on this project by yourself! If you do share tips with one another please be sure to include everyone’s name at the top of your program. Note that “sharing tips” does not mean “copied the entire program” from someone else.

  • Passwords must be at least 8 characters long (but they do not have an upper limit)
  • Passwords cannot contain the user’s username (i.e. if the username is “My1stUsername” the password cannot be “abcMy1stUsername” or “My1stUsernameABC” because the username String can be found in the password String)
  • Passwords must be a mixture of uppercase letters (A-Z), lowercase letters (a-z), digits (0-9) and a select number of special characters (#, $, % and !). The password must contain at least one of each of these types of characters in order to be valid.

You can make a copy of Part 1a and place your password validator code directly after your username validator. Here’s a sample running of the program. Note that you need to continually ask the user for a password until they supply a good one.

Enter a username: Abc123def
* Length of username: 9
* All characters are alphabetic or numeric: True
* First character is a digit: False
* Last character is a digit: False
* # of uppercase characters: 1
* # of lowercase characters: 5
* # of digit characters: 3
Username is valid!

Enter a password: apple
* Length of password: 5
  ERROR - password must be at least 8 characters long
* Username is part of password: False
* # of uppercase characters in the password: 0
  ERROR - password must contain at least one uppercase character
* # of lowercase characters in the password: 5
* # of digit characters in the password: 0
  ERROR - password must contain at least one digit character
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: APPLE
* Length of password: 5
  ERROR - password must be at least 8 characters long
* Username is part of password: False
* # of uppercase characters in the password: 5
* # of lowercase characters in the password: 0
  ERROR - password must contain at least one lowercase character
* # of digit characters in the password: 0
  ERROR - password must contain at least one digit character
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: Abc123def
* Length of password: 9
* Username is part of password: True
  ERROR - username cannot exist within password
* # of uppercase characters in the password: 1
* # of lowercase characters in the password: 5
* # of digit characters in the password: 3
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: ZZZAbc123def
* Length of password: 12
* Username is part of password: True
  ERROR - username cannot exist within password
* # of uppercase characters in the password: 4
* # of lowercase characters in the password: 5
* # of digit characters in the password: 3
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: Abc123defZZZ
* Length of password: 12
* Username is part of password: True
  ERROR - username cannot exist within password
* # of uppercase characters in the password: 4
* # of lowercase characters in the password: 5
* # of digit characters in the password: 3
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: abc123defZZZ
* Length of password: 12
* Username is part of password: False
* # of uppercase characters in the password: 3
* # of lowercase characters in the password: 6
* # of digit characters in the password: 3
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: helloWorld123
* Length of password: 13
* Username is part of password: False
* # of uppercase characters in the password: 1
* # of lowercase characters in the password: 9
* # of digit characters in the password: 3
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 0
Password is no valid, please try again

Enter a password: helloWorld123***
* Length of password: 16
* Username is part of password: False
* # of uppercase characters in the password: 1
* # of lowercase characters in the password: 9
* # of digit characters in the password: 3
* # of special characters in the password: 0
  ERROR - password must contain at least one special character
* # of invalid characters in the password: 3
  ERROR - password cannot contain any invalid characters
Password is no valid, please try again

Enter a password: helloWorld123!
* Length of password: 14
* Username is part of password: False
* # of uppercase characters in the password: 1
* # of lowercase characters in the password: 9
* # of digit characters in the password: 3
* # of special characters in the password: 1
* # of invalid characters in the password: 0
Password is valid!

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Exit mobile version