Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, August 30, 2012

CJ-22 : Check user name and password

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
public class string 
{
    public static void main(String args[])
    {
        String pass,user;
        try
        {
            DataInputStream x=new DataInputStream(System.in);
            System.out.println("Enter user name :");
            user=x.readLine();
            System.out.println("Enter password :");
            pass=x.readLine();
            if(user.equalsIgnoreCase("Priyada")&&pass.equals("java"))
                    {
                        System.out.println("LOGIN");
                    }
                    else
                       {
                              System.out.println("Invalid user name or password"); 
                       }     
        }
     catch(Exception e)
     {
     }
  }
}
=========================================================================
Output : 
Here, I am giving the user name as "Priyada" and password as "java"    .
In this program , only password is case sensitive.
In the output , if we give the correct user name and password, a message will appear as "LOGIN".
Otherwise , "Invalid user name or password"will be displayed.

run:
Enter user name :
priyada
Enter password :
java
LOGIN


==================================================================
Note : 

We can give LOGIN table as shown below : 



The program to draw table like this , will follow soon.....

No comments: