Question: Write a program that returns true if two given strings are nearly identical. Nearly identical means that either all of their characters match, or all
Write a program that returns true if two given strings are nearly identical. Nearly identical means that either all of their characters match, or all but one match. The strings can be upper or lower case and still be considered nearly identical. Both strings will also need to be the same length to be considered nearly identical.
public class Problem19 { public static void main(String[] args) { System.out.println(nearlyIdentical("Test","Tost")); // True System.out.println(nearlyIdentical("Java","J ava")); // False System.out.println(nearlyIdentical("abcdef","abddef")); // True System.out.println(nearlyIdentical("poolside","sidepool")); // False } public static boolean nearlyIdentical(String phrase1, String phrase2) { // Your code here } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
