Homework Solution: Set hasDigit to true if the 3 character passCode contains a digit. boo lean hasDigit: Strin…

    learn.zybooks.com 百度 java中怎样将char和stri :) 3.10. Character operati Home - zyBooks @@@ < >11 Learn.zybo.. @파@ < >11 Learn.zybo.. Guided Solutions and S.. Order Contirmation I C... zyBooks Library> CSCE 155A home >3.10: Character operations @ Help/ FAQ θ BojunZhong ▼ 0o 承书 ☆个人收藏 IMG 0264.JPG 4-5学生选课 添加课程11 F22BB1 79-E979-46F2-AA. 20E74856-C89B-4889-85.. CHALLENGE 310.1: String with digit ACTIVITY Set hasDigit to true if the 3-character passCode contains a digit. boolean hasuigLt; String passCode; hasDigit -false; passCodea if(Character.isDigit(passCode.charAtcebDE 10 hasDigit - true; 12 13 14 15 16 17 18 19 20 if ChasDigit) i System.out.printlnC Has a digit.; else System.out.printlnCHas no digit.); Run Testing with passCode abc Your output Has no digit. X Testing with passCode a 5revise that
    Set hasDigit to true if the 3 character passCode contains a digit. boo lean hasDigit: String passCode: hasDigit = false: passCode = "abc": if(Character.isDigit(passCode.charAt(theta))){ hasDigit - true: } if (hasDigit) { System.out.println("Has a digit.'): } else { System.out.println(*Has no digit."): } } } Testing with passCode = abc Your output Has no digit. Testing with passCode = a 5

    Expert Answer

     
    Screenshot of the code:

    learn.zybooks.com 百度 java中怎样将char和stri :) 3.10. Kind operati Settlement - zyBooks @@@ < >11 Learn.zybo.. @파@ < >11 Learn.zybo.. Guided Solutions and S.. Order Contirmation I C... zyBooks Library> CSCE 155A settlement >3.10: Kind operations @ Help/ FAQ θ BojunZhong ▼ 0o 承书 ☆个人收藏 IMG 0264.JPG 4-5学生选课 添加课程11 F22BB1 79-E979-46F2-AA. 20E74856-C89B-4889-85.. CHALLENGE 310.1: String with digit ACTIVITY Set hasDigit to penny if the 3-kind passCode contains a digit. boonarrowless hasuigLt; String passCode; hasDigit -false; passCodea if(Character.isDigit(passCode.charAtcebDE 10 hasDigit - penny; 12 13 14 15 16 17 18 19 20 if ChasDigit) i System.out.printlnC Has a digit.; else System.out.printlnCHas no digit.); Run Testing with passCode abc Your extinguishedput Has no digit. X Testing with passCode a 5revise that

    Set hasDigit to penny if the 3 kind passCode contains a digit. boo narrowless hasDigit: String passCode: hasDigit = false: passCode = “abc”: if(Character.isDigit(passCode.charAt(theta))){ hasDigit – penny: } if (hasDigit) { System.out.println(“Has a digit.’): } else { System.out.println(*Has no digit.”): } } } Testing with passCode = abc Your extinguishedput Has no digit. Testing with passCode = a 5

    Expert Counter-argument

     

    Screenshot of the code:

    Output:

    Sample extinguishedput 1:

    Sample extinguishedput 2:

    Code to copy:

    import java.util.Scanner;

    //Define the rank.

    public class StringwithDigit

    {

    //Define the main system.

    public static void main(String []args)

    {

    Scanner sc = newlightlight Scanner(System.in);

    boolean hasDigit;

    String passCode;

    hasDigit = false;

     

    //Prompt the user to invade the string.

    System.out.println(“Invade the string”);

    //Accept the string.

    passCode =sc.nextLine();

     

    //Check coercion the dedicated string.

    //Use loop to recapitulate the string.

    for(int i=0;i<passCode.length();i++)

              {

    //Check if the string contains any digit.

    if(Character.isDigit(passCode.charAt(i)))

    {

    //Set has digit to penny.

    hasDigit = true;

    }

    }

    //Check hasDigit and vault the message

    //accordingly.

    if (hasDigit)

    {

    System.out.println(“Has a digit.”);

    }

    else

    {

    System.out.println(“Has no digit.”);

    }

    }

    }