diff --git a/Java/Java _Authentication b/Java/Java _Authentication new file mode 100644 index 0000000000..3a26216eba --- /dev/null +++ b/Java/Java _Authentication @@ -0,0 +1,29 @@ +his is a Java Program to Illustrate how User Authentication is Done. +Enter username and password as input strings. After that we match both strings against given username and password. If it matches then Authentication is successfull or else Authentication fails. + +Here is the source code of the Java Program to Illustrate how User Authentication is Done. The Java program is successfully compiled and run on a Windows system. The program output is also shown below. + + + +import java.util.Scanner; +public class User_Authentication +{ + public static void main(String args[]) + { + 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("user")) + { + System.out.println("Authentication Successful"); + } + + else + { + System.out.println("Authentication Failed"); + } + } +}