View the step-by-step solution to:


my question somewhat pertains to a simpler version of this. My task is to set hasDigit = true if the passcode

contains a digit:

im confused about what 'code' im supposed to use? im only allowed to edit the line that has '    Character.isDigit(userStr.charAt(3)); ' in its entirety

 public static void main (String [] args) {

   Scanner scnr = new Scanner(;

   boolean hasDigit;

   String passCode;

   hasDigit = false;

   passCode =;


   if (hasDigit) {

     System.out.println("Has a digit.");


   else {

     System.out.println("Has no digit.");




Top Answer

View the full answer

Has a digit.
Program finished with exit code 0
Press ENTER to exit console.

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question