5 points static boolean Q4 String input1 String input2f Comp

5 points static boolean Q4 (String input1 String input2)f Compare the 2 input strings ignoring case and whitespace. Return true if the inputs are equal under these conditions false otherwise. Note that whitespace includes spaces new lines, and tabs. Example \"ltHElLO W OR 1 DVn In\" and \"hel loworld\" should return true return false;

Solution

ExampleCompareString.java

import java.util.Scanner;
public class ExampleCompareString {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       System.out.println(\"Enter first string : \");
String s1 = scan.next();
System.out.println(\"Enter second string : \");
String s2 = scan.next();
String a = (s1.replaceAll(\"\\\\w\",\"\"));
String b = (s2.replaceAll(\"\\\\w\",\"\"));

      boolean c = Q4(a, b);
   }

   public static boolean Q4(String n1, String n2) {
        boolean n3;
        if(n1.equalsIgnoreCase(n2)){
        n3=true;
    }else{
        n3=false;
    }
     System.out.println(n3);
      return false;
   }
}

Output:-

 5 points static boolean Q4 (String input1 String input2)f Compare the 2 input strings ignoring case and whitespace. Return true if the inputs are equal under t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site