Code:
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String username, tempuser;
username = "testuser";
{System.out.println("Please enter your username.");
tempuser = input.nextLine();
if (!tempuser.equals(username)){
System.out.println("Wrong username.");
Test.main(null);}
else
Test.Access();
}
}
public static void Access() {
Scanner input2 = new Scanner(System.in);
String password, temppassword;
password = "testpass";
System.out.println("Please enter your password.");
temppassword = input2.nextLine();
if (!temppassword.equals(password)){
System.out.println("Wrong password.");
Test.main(null);}
else
System.out.println("Access Granted!");}
}
I am a newbie to Java and have been learning and testing. My question is this, is the code above proper for a simple protected program in its current state?
Comment