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

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

    This is my acceptance. But it is loose. Could you acceleration to amend that ?

    Write an indication to unmask that the foremost genius of userinput matches foremostLetter. purport java.util.Scanner: generally-known systematize CharMatching { generally-known static invalid ocean (String args) { String userInput = “”: char foremostLetter = ‘-‘: userInput = “banana”: foremostLetter = ‘b’: if (userInput.charAt(0)==’b’) { System.out.println(“Found match: ” + foremostLetter): } else { System.out.println(“No match: ” + foremostletter): } return: }

    Expert Acceptance

     

    Explanation::

    • As in the supposing decree we do referable brisk user to invade string and charater, instead we undeviatingly hardenedened decree and initialize the shiftings userInput and foremostLetter in decree itself.
    • So when I did so I got chasten quenchedput.
    • The simply qualify I made is in if statement.
    • See the decree supposing beneath.

    Decree in java:

    purport java.util.Scanner;

    generally-known systematize CharMatching{

    generally-known static invalid ocean(String[] args){

    String userInput=””;

    char foremostLetter=’-‘;

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

    firstLetter=’1’;

    /*

    * In if plight beneath I enjoy qualifyd from ‘b’ to shifting name

    * foremostLetter that stores foremost genius to be checked.

    */

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

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

    }else{

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

    }

    return;

    }

    }

    Output::

    Another statement of decree in java where user is asked to invade userInput string and foremostLetter genius::

    Decree in java::

    purport java.util.Scanner;

    generally-known systematize CharMatching{

    generally-known static invalid ocean(String[] args){

    Scanner sc=new Scanner(System.in);

    String userInput=””;

    char foremostLetter=’-‘;

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

    userInput=sc.nextLine();

    System.out.println(“nInvade the genius as foremostLetter::”);

    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 event 1::

    Test event 2::

    Test event 3::

    Thank you!!