Martes, Nobyembre 29, 2011

Create a simple Log-in program using BufferedReader specify the Username and Password will determine that you are log-on to the System

import java.io.*;

public class login{
String user,pass;
public static void main(String[] args)throws IOException{
BufferReader in = new Bufferedreader(new InputStreamReader(System.in));
System.out.print("Usename: ");
user=in.reaLine();
System.out.print("Password: ");
pass=in.reaLine();
if(user.equals("Java") && pass.equals("Jedi"))
{
System.out.print("log in OK");
}
else
{
System.out.print("ERROR!");
}
 }
}

1 komento:

  1. what if, the user will input the invalid users? is it okay to use the while statement? pls,, email me at jaysicayan09@yahoo.com ,, thnkx!

    TumugonBurahin