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
Create an application using PyQt. The user must be prompted for the name of a country...
Create an application using PyQt. The user must be prompted for the name of a country (e.g. Spain) and a single character (e.g ‘a’). The application must read the name of the country and count the number of occurrences of the character in the country name. The count should be case-insensitive. Thus, if ‘c’ is entered as the character then both capital letter ‘C’ and small letter ‘c’ in the string should be counted. The count must be displayed. The...
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.
Description Your program must start and keep dialog with the user. Please create the first prompt...
Description Your program must start and keep dialog with the user. Please create the first prompt for the dialog. After that your program must accept the user’s response and echo it (output to screen) in upper case and adding the question mark at the end. The program must run endlessly until the user say “stop” in any combination of cases. Then you program must say “GOODBYE!” and quit. Example: HELLO, I AM THE PROGRAM Hi, I am Michael HI, I...
The following questions deal with domain name registration. (5 Marks) a) What is ICANN b) what...
The following questions deal with domain name registration. a) What is ICANN b) what is ICANN’s UDRP
Having those files please adjust the following tasks. When the user fills out the registration, all...
Having those files please adjust the following tasks. When the user fills out the registration, all information is inserted into a database table. When the user signs in, all information is verified from the database table. You can either create your own table on your machine or use the demo server table for testing. Remember the table name and the fields must be exactly as shown below. If you are using your own table, you must change the connection info...
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(%)...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT