I have a simple problem that says:
A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string and print out a message as to whether or not the string entered would be considered a valid password.
I need help on completing this code. I have this pseudocode that I can't workout into Java code:
print "enter new password"
input newPassword
digitCounter =0
letterCounter = 0
for I = 0 to newPassword.length() by 1
c = newPassword.charAt(i)
if c is a digit
increment digitCounter
else if c is a letter
increment letterCounter
endif
endFor
if newPassword.length() >= 6 and digitCounter > 0 and letterCounter > 0
print "the password is valid"
else
print " password rejected, must be at least 6 characters long and be a mix of letters and digits "
endif
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
So far all I have is this for the Java code:
import java.util.Scanner;
public class Password
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
String thePassword;
int len, i, letterCounter = 0, digitCounter = 0;
char c;
Len = thePassword.length();
System.out.print("Enter the password: ");
thePassword = in.nextLine();
for (i = 0,i = len, )
{
c = in.charAt(1);
if ()
}
}
}