1) the source code (.java file), and
2) the screenshot of running results of each question.
(Comparing Portions of Strings) Write an application to compare two strings input by the user. The application should state whether the strings are equal. Ignore the case of the characters when performing the comparison.
import java.util.Scanner; public class CompareStrings { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter first string: "); String s1 = in.nextLine(); System.out.print("Enter second string: "); String s2 = in.nextLine(); if (s1.equalsIgnoreCase(s2)) { System.out.println("These strings are equal"); } else { System.out.println("These strings are not equal"); } } }
Get Answers For Free
Most questions answered within 1 hours.