Set has Digit to true if the 3-character passCode contains a digit.

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

The has Digit property is set to true if the 3-character passcode containing a digit contains a digit.

Table of Contents

3-character passCode

import java.util.Scanner;
public class CheckingPasscodes {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
boolean hasDigit;
String passCode;
hasDigit = false;
passCode = scnr.next();

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

// the string is passCode and not userInput
// also you didn’t declare let0, let1, let2
int let0 = passCode.charAt(0);
int let1 = passCode.charAt(1);
int let2 = passCode.charAt(2);
if ((Character.isDigit(let0) || Character.isDigit(let1) || Character.isDigit(let2))){
hasDigit = true;
}
if (hasDigit) {
System.out.println(“Has a digit.”);
}
else {
System.out.println(“Has no digit.”);

Read Also

Picture of Steve Wilkos with hair?!?

 

See also  What order are the songs in Grease?