Yes you do have to program it first.
Answer
The answer and procedures of the exercise are attached in the following archives.
Step-by-step explanation:
You will find the procedures, formulas or necessary explanations in the archive attached below. If you have any question ask and I will aclare your doubts kindly.
Answer:
Explanation:
The following program creates a function called region_Matches that takes in two strings as arguments as well as an int for starting point and an int for amount of characters to compare. Then it compares those characters in each of the words. If they match (ignoring case) then the function outputs True, else it ouputs False. The test cases compare the words "moving" and "loving", the first test case compares the words starting at point 0 which outputs false because m and l are different. Test case 2 ouputs True since it starts at point 1 which is o and o.
class Brainly {
public static void main(String[] args) {
String word1 = "moving";
String word2 = "loving";
boolean result = region_Matches(word1, word2, 0, 4);
boolean result2 = region_Matches(word1, word2, 1, 4);
System.out.println(result);
System.out.println(result2);
}
public static boolean region_Matches(String word1, String word2, int start, int numberOfChars) {
boolean same = true;
for (int x = 0; x < numberOfChars; x++) {
if (Character.toLowerCase(word1.charAt(start + x)) == Character.toLowerCase(word2.charAt(start + x))) {
continue;
} else {
same = false;
break;
}
}
return same;
}
}