Sunday, April 8, 2018

THREE ATTEMPTS LOGIN SYSTEM IN JAVA

A very simple program that will ask the user to give username and password it will count the number of attempts of the user maximum of three attempts using Java as my programming language.

I am currently accepting programming, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.


Program Listing


Pass.java

package login;

import java.util.Scanner;

/**
 * NetBeans IDE 8.2
 * @author Mr. Jake R. Pomperada
 * April 6, 2018  Friday
 * Bacolod City, Negros Occidental
 */

public class Pass {
    
   
   
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
       String user,pass;
        
       int attempts=0;
        
         System.out.println("===== THREE ATTEMPTS LOGIN SYSTEM IN JAVA =====");
         System.out.println("\n");
        do {
           
            System.out.print("Enter User Name : ");
            user = scanner.next();
            
            System.out.print("Enter Password :  ");
            pass = scanner.next();
            
              attempts++;
            
            if (!user.equals("user")  && !pass.equals("user") && attempts !=3){
                System.out.println("\n");
                System.out.print("Wrong Username or Password Attempt No " + attempts + ".");
                System.out.println("\n\n");
            }
            else {
                
                break;
                
            }
            
           
            
        } while (!user.equals("user")  && !pass.equals("user") && attempts !=3);
                
             if (attempts==4) {
                 System.out.println("After three attempts");
                 System.out.println("Access Denied to the system.");
               
             }
             else {
                 System.out.println("\n\n");
                 System.out.println("Welcome to the System " + user);
                 System.out.println("\n\n");
             } 
      
          
          
             scanner.close();
    
     }
}






No comments:

Post a Comment