I have to create a NetBeans GUI that asks the user a username and a password. The password must be a minimum of 8 characters in length. If it is not 8 characters a message must go out to user to notify them that it is not an appropriate password. If the password is 8 characters, a random number between 1 and 100 (inclusive) is added to the end of the password.
I wasn't given any instructions on how to go about creating this application and the instructor is not responding to my emails in time before the due date which is why I'm asking this on Stack Overflow. Please help me figure out how to code for this type of program.
I've tried addressing a for loop so that the entered password has something to be compared to. I was thinking of adding an if statement so that if it does not meet the requirements, the appropriate message would be sent out. The code below is what I have so far...
String strUser, password;
strUser=this.txtInput1.getText();
password=this.txtInput2.getText();
if(password.equals(this.value.length < 8))
{
this.txtOutput.setText("Your Password is Less Than 8 Characters");
}
else if(password.equals(this.value.length > 8))
{
this.txtOutput.setText("Your Password is More than 8 Characters");
}
else if(password.equals(this.value.length == 8))
{
for (int i = 1; i <= 10 ; i++)
{
int Random = (int)(Math.random()*100);
this.txtOutput.setText("Password:"+ password + Random);
}
this.txtOutput.setText("UserName:" + strUser);
}
}
The GUI is supposed to look like this:
Enter user: geekysquirrel
Enter Password (minimum of 8 characters): programmer
OUTPUT:
User: geekysquirrel Password:programmer98