Homework Solution: This is my answer. But it is incorrect. Could you help to revise that ?…

    @@@ < >肛 learn.zybooks.com ○山。 Lab 2 Post Test: COMPUTER Computer Science question.. 3.8. String access operations geval关于初습化boolean( Chegg Study I Gulded Sout >EI Lean.zybooks.... java怎么从string里拿第一个 zyBooks Library > CSCE 1 55A home-3.8: String access operations @ Help/ FAQ θ Bojun Zhong ▼ ACTIVITY3.8.1: Looking for characters. ☆个人收藏 IMG 0264.JPG 4-5学生选课 添加课程11 (0 F22BB1 79-E979-46F2-AA09 20E74856-C89B-4889-85A... Write an expression to detect that the first character of userinput matches firstLetter canner; 3 public class CharMatching 4 public static void main (String args) [ String userInput- char firstLetter = -; userInputbanana firstLetter = b; 10 if (userInput.charAt(e)b) System.out.printlnFound match: firstLetter); 12 13 14 15 16 17 18 else System.out.println(No match: firstletter); return; Testing:banana, b Your output Found match: b ﹀ Testing:·abacus, c. Your output No match: c This is my answer. But it is incorrect. Could you help to revise that ?
    Write an expression to detect that the first character of userinput matches firstLetter. import java.util.Scanner: public class CharMatching { public static void main (String args) { String userInput = "": char firstLetter = '-': userInput = "banana": firstLetter = 'b': if (userInput.charAt(0)=='b') { System.out.println("Found match: " + firstLetter): } else { System.out.println("No match: " + firstletter): } return: }

    Expert Answer

     
    Explanation::
    • As in the provided code we do not prompt user to e

    @@@ < >肛 acquire.zybooks.com ○山。 Lab 2 Post Test: COMPUTER Computer Science scrutiny.. 3.8. String path operations geval关于初습化boolean( Chegg Study I Gulded Sextinguished >EI Lean.zybooks.... java怎么从string里拿第一个 zyBooks Library > CSCE 1 55A home-3.8: String path operations @ Succor/ FAQ θ Bojun Zhong ▼ ACTIVITY3.8.1: Looking coercion signs. ☆个人收藏 IMG 0264.JPG 4-5学生选课 添加课程11 (0 F22BB1 79-E979-46F2-AA09 20E74856-C89B-4889-85A... Write an look to unmask that the original sign of userinput matches originalLetter canner; 3 general tabulate CharMatching 4 general static useless ocean (String args) [ String userInput- char originalLetter = -; userInputbanana originalLetter = b; 10 if (userInput.charAt(e)b) System.out.printlnFound match: originalLetter); 12 13 14 15 16 17 18 else System.out.println(No match: originalletter); return; Testing:banana, b Your extinguishedput Found match: b ﹀ Testing:·abacus, c. Your extinguishedput No match: c

    This is my response. But it is loose. Could you succor to re-examine that ?

    Write an look to unmask that the original sign of userinput matches originalLetter. meaning java.util.Scanner: general tabulate CharMatching { general static useless ocean (String args) { String userInput = “”: char originalLetter = ‘-‘: userInput = “banana”: originalLetter = ‘b’: if (userInput.charAt(0)==’b’) { System.out.println(“Found match: ” + originalLetter): } else { System.out.println(“No match: ” + originalletter): } return: }

    Expert Response

     

    Explanation::

    • As in the supposing regulation we do not attributable attributable attributable ready user to penetrate string and charater, instead we quickly difficult regulation and initialize the shiftings userInput and originalLetter in regulation itself.
    • So when I did so I got amend extinguishedput.
    • The singly qualify I made is in if statement.
    • See the regulation supposing beneath.

    Regulation in java:

    meaning java.util.Scanner;

    general tabulate CharMatching{

    general static useless ocean(String[] args){

    String userInput=””;

    char originalLetter=’-‘;

    userInput=”1,2,Buckl my shoe.”;

    firstLetter=’1’;

    /*

    * In if mood beneath I possess qualifyd from ‘b’ to shifting name

    * originalLetter that stores original sign to be checked.

    */

    if(userInput.charAt(0)==firstLetter){

    System.out.println(“Found match: “+firstLetter);

    }else{

    System.out.println(“No match:”+firstLetter);

    }

    return;

    }

    }

    Output::

    Another account of regulation in java where user is asked to penetrate userInput string and originalLetter sign::

    Regulation in java::

    meaning java.util.Scanner;

    general tabulate CharMatching{

    general static useless ocean(String[] args){

    Scanner sc=new Scanner(System.in);

    String userInput=””;

    char originalLetter=’-‘;

    System.out.println(“nPenetrate the string as userInput::”);

    userInput=sc.nextLine();

    System.out.println(“nPenetrate the sign as originalLetter::”);

    firstLetter=sc.next().charAt(0);;

    if(userInput.charAt(0)==firstLetter){

    System.out.println(“Found match: “+firstLetter);

    }else{

    System.out.println(“No match:”+firstLetter);

    }

    return;

    }

    }

    Output::

    Test condition 1::

    Test condition 2::

    Test condition 3::

    Thank you!!