Apr 21, 2022

User ID & Password Validation Program In Java | Androidpro Education

Program 


package in.input;

import java.util.Scanner;

public class Input {
    public static void main(String[] args) {
//single line comment

        String username, password;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter username:");//username:user
        username = s.nextLine();

        System.out.print("Enter password:");//password:user
        password = s.nextLine();

        if(username.equals("user") && password.equals("abcd33"))
        {
            System.out.println("Authentication Successful");
        }
        else
        {
            System.out.println("Authentication Failed");
        }
    }
}

// www.androidpro.in

// Output
// Enter username:user
// Enter password:abcd33
// Authentication Successful

// Process finished with exit code 0

Share:

0 Comments: