Respuesta :
Answer:
if(Character.toUpperCase(firstLetter)==Character.toUpperCase(userInput.charAt(0)))
Explanation:
The given source code is an illustration of characters and strings in Java program.
To complete the code segment, the comment /* Your solution goes here */ in the program, should be replaced with any of the following expressions:
- Character.toUpperCase(firstLetter)==Character.toUpperCase(userInput.charAt(0))
- Character.toLowerCase(firstLetter)==Character.toLowerCase(userInput.charAt(0))
Using the first instruction above
- Variable firstLetter will first be converted to upper case
- The first character of userInput will then be extracted using charAt(0)
- The first character is then converted to upper case
- Lastly, both characters are compared
So, the complete code (where comments are used to explain each line) is as follows:
//This imports the Scanner library
import java.util.Scanner;
//This defines the program class
public class Main {
//This defines the program method
public static void main (String [] args) {
//This creates a Scanner object
Scanner scnr = new Scanner(System.in);
//This declares variables userInput and firstLetter
String userInput; char firstLetter;
//This gets input for userInput
userInput = scnr.nextLine();
//This gets input for firstLetter
firstLetter = scnr.nextLine().charAt(0);
//This checks if the first letter of userInput matches with variable firstLetter
if (Character.toUpperCase(firstLetter)==Character.toUpperCase(userInput.charAt(0))){
//If yes, found match is printed
System.out.println( "Found match: "+firstLetter); }
else{
//If otherwise, no match is printed
System.out.println("No match: "+ firstLetter);
}
}
}//Program ends here
See attachment for the complete code and the sample run
Read more about java programs at:
https://brainly.com/question/2266606