Question

In: Computer Science

A successful new user registration requires the following valid data: ⦁   User name: it must start...

A successful new user registration requires the following valid data:

⦁   User name: it must start with a letter and consist of only letters and digits without any space character. User name is case insensitive. Different users must have different user names.
⦁   Password: it must have at least six characters, consist of only letters, digits, and special characters (@, #, $, ^, &), and at least one upper-case letter, one lower-case letter, one digit, and one special character.
⦁   First name: it must consist of only letters
⦁   Last name: it must consist of only letters
⦁   Email address: it must be a valid email address
⦁   Phone number: it must include three-digit area code and seven digit phone number

Describe comprehensive acceptance criteria for the “register new user” and “login” user stories which uses the following method names:

⦁   public String registerNewUser(String userName, String password, String reenteredPassword, String firstName, String lastName, String email, String phone)

⦁   public UserAccount login(String userName, String password)

The acceptance criteria for “register new user” should consider whether or not reenteredPassword matches password.

Solutions

Expert Solution

Implementation in JAVA;

code:

import java.util.HashMap;
import java.util.Scanner;

public class Username_password_Checker {
  
//   map for Storing data
   static HashMap<String , Username > map = new HashMap<>();

//   main method
   public static void main(String[] args) {
      
       Scanner s= new Scanner(System.in);
      
//       enter data from users
       System.out.println("\nRegister 1st user !!\n");
      
       System.out.println("Enter username : ");
       String uname = s.next();
      
       System.out.println("Enter Password : ");
       String pass = s.next();
      
       System.out.println("Re-Rnter Password : ");
       String repass = s.next();
      
       System.out.println("Enter Fname : ");
       String fname = s.next();
      
       System.out.println("Enter Lname : ");
       String lname = s.next();
      
       System.out.println("Enter Email : ");
       String email = s.next();
      
       System.out.println("Enter Phone : ");
       String phone = s.next();
      
       registernewuser(uname,pass,repass,fname,lname,email,phone);
      
      
      
System.out.println("\nRegister 2nd user !!\n");
      
       System.out.println("Enter username : ");
       String uname1 = s.next();
      
       System.out.println("Enter Password : ");
       String pass1 = s.next();
      
       System.out.println("Re-Rnter Password : ");
       String repass1 = s.next();
      
       System.out.println("Enter Fname : ");
       String fname1 = s.next();
      
       System.out.println("Enter Lname : ");
       String lname1 = s.next();
      
       System.out.println("Enter Email : ");
       String email1 = s.next();
      
       System.out.println("Enter Phone : ");
       String phone1 = s.next();
      
       registernewuser(uname1,pass1,repass1,fname1,lname1,email1,phone1);
      
      
       System.out.println("\n Account login check \n");
      
       System.out.println("Enter username : ");
       String username = s.next();
      
       System.out.println("Enter Password : ");
       String password = s.next();
      
       account_login(username,password);
      
      
      
      
   }
  
//   checking account login
   public static void account_login(String username, String password) {
      

      
       if(map.containsKey(username)) {
          
           Username un = map.get(username);
          
           if(password.equals(un.password)) {
              
               System.out.println("Username : "+username);
               System.out.println("First_name : "+un.fname);
               System.out.println("Last_Name : "+un.lname);
               System.out.println("Email : "+un.email);
               System.out.println("Phone no. : "+un.phone);
           }
          
           else {
          
               System.out.println("Invalid Password!!!");
           }
          
          
       }
      
       else {
      
           System.out.println("Username not Registered ! ");
          
       }
      
      
      
   }
  
//   register new user
  
   public static void registernewuser(String username, String password, String reentered_pass, String fname, String lname, String email, String phone) {
      
      
       Scanner s= new Scanner(System.in);
      
      
       if(! isvalid_username(username)) {
          
           System.out.print("Invalid username!!!\nPlease enter Valid Username : ");
          
           username = s.next();
          
           if(! isvalid_username(username)) {
              
               System.out.print("Invalid username!!!\nPlease enter Valid Username : ");
              
               username = s.next();
              
           }
       }
      
      
       if(map.containsKey(username)) {
          
           System.out.println("User Already Registred!!");
          
           return;
          
       }
      
      
if(! isvalispassword(password)) {
          
           System.out.print("Invalid password!!!\nPlease enter Valid password : ");
          
           password = s.next();
          
           if(! isvalid_username(password)) {
              
               System.out.print("Invalid password!!!\nPlease enter Valid password : ");
              
               password = s.next();
              
           }
       }
      

if(! isreenteredpass(password,reentered_pass)) {
          
           System.out.print("Invalid password!!!\nPlease enter Valid password : ");
          
           reentered_pass = s.next();
          
           if(! isreenteredpass(password,reentered_pass)) {
              
               System.out.print("Invalid password!!!\nPlease enter Valid password : ");
              
               reentered_pass = s.next();
              
           }
       }
  

  
if(! isvalisname(fname)) {
          
           System.out.print("Invalid First name!!!\nPlease enter Valid First name : ");
          
           fname = s.next();
          
           if(! isvalisname(fname)) {
              
               System.out.print("Invalid First name!!!\nPlease enter Valid First name : ");
              
               fname = s.next();
              
           }
       }
  
if(! isvalisname(lname)) {
          
           System.out.print("Invalid last name!!!\nPlease enter Valid Last name : ");
          
           lname = s.next();
          
           if(! isvalisname(lname)) {
              
               System.out.print("Invalid Last name!!!\nPlease enter Valid Last name : ");
              
               lname = s.next();
              
           }
       }
  
  
if(! isValidmail(email)) {
          
           System.out.print("Invalid email !!!\nPlease enter Valid email : ");
          
           email = s.next();
          
           if(! isValidmail(email)) {
              
               System.out.print("Invalid email !!!\nPlease enter Valid email : ");
              
               email = s.next();
              
           }
       }
  
  
if(! isvalidphone(phone)) {
          
           System.out.print("Invalid phone !!!\nPlease enter Valid phone : ");
          
           phone = s.next();
          
           if(! isvalidphone(phone)) {
              
               System.out.print("Invalid phone !!!\nPlease enter Valid phone : ");
              
               phone = s.next();
              
           }
       }
  
  
  
Username un = new Username( password, reentered_pass, fname, lname, email, phone);
  
       map.put(username,un);
  
      
   }
  
   ////////////////////////////////////////////////////////////////////////////////////////
  
//   check validations
   public static boolean isvalid_username(String username) {
      
       String us = username;
  
       if(Character.isLetter(us.charAt(0))) {
          
           for(int i=1;i<us.length();i++) {
              
               if(!Character.isLetterOrDigit(us.charAt(i))) {
                   return false;
                  
               }
              
           }
          
       }
      
       else {
          
           return false;
       }
      
       return true;
      
   }
  
  
  
   public static boolean isvalispassword(String pass) {
      
       int upper=0;
       int lower=0;
       int special=0;
       int digit=0;
       int letter=0;
      
      
       if(pass.length()<6) {
           return false;
       }
      
       for(int i=0;i<pass.length();i++) {
          
           if(Character.isDigit(pass.charAt(i))) {
               digit++;
           }
          
           else if(Character.isLetter(pass.charAt(i))) {
              
               letter++;
              
               if(Character.isUpperCase(pass.charAt(i))) {
                   upper++;
               }
              
               else if(Character.isLowerCase(pass.charAt(i))) {
                   lower++;
               }
              
               }
          
           else if(pass.charAt(i)=='@' || pass.charAt(i)=='#' || pass.charAt(i)=='$'|| pass.charAt(i)=='^' ||pass.charAt(i)=='&')
           {
               special++;
           }
          
           else {
              
               return false;
           }
          
          
       }
      
       if(upper>0 && lower>0 && special>0 && digit>0 && letter>0 ) {
          
           return true;
          
       }
      
       else {
           return false;
       }
      
      
   }
  
  
   public static boolean isreenteredpass(String pass, String re_pass) {
      
       if(pass.equals(re_pass)) {
      
           return true;
       }
      
       else {
           return false;
       }
      
   }
  
  
   public static boolean isvalisname(String name) {
  
       for(int i=0;i<name.length();i++) {
          
           if(! Character.isLetter(name.charAt(i))) {
               return false;
           }
          
       }
      
       return true;
      
   }
  
  
   public static boolean isValidmail(String email) {
      
       String regex = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
       return email.matches(regex);
       }
  
  
   public static boolean isvalidphone(String phone) {
      
       if(phone.length()!=10) {
          
           return false;
          
       }
      
       for(int i=0;i<phone.length();i++) {
          
           if(! Character.isDigit(phone.charAt(i))) {
              
               return false;
           }
          
       }
      
       return true;
   }
  

}

//username class

class Username{
  
   String password;
   String reeneterdpass;
   String fname;
   String lname;
   String email;
   String phone;
  
//   constructor
   public Username(String password, String reeneterdpass, String fname, String lname, String email, String phone) {
      
       this.password = password;
       this.reeneterdpass= reeneterdpass;
       this.fname= fname;
       this.lname= lname;
       this.email= email;
       this.phone= phone;
      
   }
  
  
}

/////////////////////////////////////////////////////////////////////////////////////////

SAMPLE OUTPUT;

// PLEASE THUMBS-UP AND RATE POSITIVELY
If you have any doubt regarding this question please ask me in commnets
// THANK YOU:-)



Related Solutions

Tom wants to start a new project. A project requires a start up cost of $11000...
Tom wants to start a new project. A project requires a start up cost of $11000 today and 20 annual cost of $4500 starting in one year. Starting at the end of the 21th year, the project returns 10 annual payments of $Y. Find Y so that the project yields an annual effective rate of 5% over the 30 years. PLZ by hand and not excel
This program must be in java, use printf, and request user input for a file name....
This program must be in java, use printf, and request user input for a file name. NameSubsLast3 (30 points) Write a program that does the following. Write a program that does the following. Requests the name of an input file and uses it to create an input file Scanner. Requests the name of an output file and uses it to create a PrintWriter. I have posted firstNames.txt and outNames.txt in the homework for Lesson 6. Calls createArray to create a...
Successful new product creation is a collective achievement that requires the energy and commitment of multiple...
Successful new product creation is a collective achievement that requires the energy and commitment of multiple functions in the organization. Describe the Kano Model and explain how the Kano Model works to create new B2B products and services. Explain how, overtime, the model requires changes to new features/products. Include at least two examples of B2B products and/or services.
The following data were collected on the yearly registration for a six sigma seminar at the...
The following data were collected on the yearly registration for a six sigma seminar at the University of Malaya Tahun/Year Pendaftaran/ Registration 1 400 2 600 3 400 4 500 5 1000 6 800 7 700 8 900 9 1200 10 1400 a. Calculate a 3-year moving average to forecast registration from year 4 to year 11.
Data Network Design & Evaluation 1. User Requirements: Name three user requirements and explain them briefly....
Data Network Design & Evaluation 1. User Requirements: Name three user requirements and explain them briefly. 2. Application Requirements: Describe the different types of applications based on their performance requirements.
If the simple CAPM is valid, which of the following situations are possible? You must provide...
If the simple CAPM is valid, which of the following situations are possible? You must provide an explanation. Consider each case independently. Your answer should begin with: This is possible or This is not possible because… For each case, M is the market portfolio and F is the risk-free asset a Portfolio Expected return (%) Standard deviation(%) A 10 15 B 5 20 b. Portfolio Expected return(%) Beta A 10 1.1 B 9 1.2 c Portfolio Expected return(%) Standard deviation(%)...
A start-up firm as developed a new email app that allows the user to decide what...
A start-up firm as developed a new email app that allows the user to decide what mail gets into their mail box. This company doesn't have a lot of start-up capital and they are funded by a Venture Capital firm that wants an expected 18% return. They are going to use the Agile model and release various versions of their app overtime as they see what works. There 3- year start up plan includes: Initial Development Expenses of $100,000 per...
User ADT: Describes and manipulates user information. You must track the following information about a user / provide the following methods:
• User ADT: Describes and manipulates user information. You must track the following information about a user / provide the following methods:o usernameo firstNameo lastNameo a list of the 10 most recently purchased itemso A user can bid on and purchase ItemsThe User class should have a default constructor, as well as one accepting all parameters. It should also provide accessor (getter) and mutator (setter) methods for appropriate methods. By default, a user is able to buy products only (not...
Need this program in python. The data must be taken from user as input. Write a...
Need this program in python. The data must be taken from user as input. Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done...
C# Create an application that asks the user to enter their new password. The password must...
C# Create an application that asks the user to enter their new password. The password must be at least 6 characters long. Develop a custom exception handling case that checks for the password length. (hint: use " .Length " built-in method). If the new password is less than 6 characters long the custom exception should output an error message.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT