set hasDigit to true if the 3character passCode contains a d

set hasDigit to true if the 3-character passCode contains a digit

(Needs to be in Java)
set hasDigit to true if the 3-character passCode contains a digit

(Needs to be in Java)
set hasDigit to true if the 3-character passCode contains a digit

(Needs to be in Java)

Solution


public final boolean hasDigit(String passcode) {
boolean hasDigit = false;
if (passcode != null && passcode.isEmpty()) {
if(passcode.lenght() !=3)
System.out.println(\"The passcode lenght is not equal to 3\");
else{
if (Character.isDigit(passcode.charAt(0))) {
hasDigit = true;
}
if (Character.isDigit(passcode.charAt(1))) {
hasDigit = true;
}
if (Character.isDigit(passcode.charAt(2))) {
hasDigit = true;
}
}
System.out.println(hasDigit);
}
else
System.out.println(\"Passcode doesnot contain digit\");
}

 set hasDigit to true if the 3-character passCode contains a digit (Needs to be in Java) set hasDigit to true if the 3-character passCode contains a digit (Need

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site