In: Computer Science
In Java please.
Part I:
Part II:
Main.java
import java.util.*;
import java.lang.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("enter any two strings");
String s1 = sc.nextLine();
String s2 = sc.nextLine();
String con = s1+s2;
System.out.println("concatenated string is: "+ con);
if(s1.equalsIgnoreCase(s2))
{
System.out.println("Both strings are equal");
}
else{
System.out.println("Both strings are equal");
}
System.out.println("String when converted to upper case:");
System.out.println(s1.toUpperCase());
System.out.println(s2.toUpperCase());
System.out.println("after replacing d with e");
System.out.println(s1.replace('d','e'));
System.out.println(s2.replace('d','e'));
System.out.println("enter third string");
String s3 = sc.nextLine();
if(s1.endsWith(s3))
{
System.out.println(s1+"ends with "+s3);
}
else{
System.out.println(s1+" doesnt ends with "+s3);
}
if(s2.endsWith(s3))
{
System.out.println(s2+"ends with "+s3);
}
else{
System.out.println(s2+"doesnt ends with "+s3);
}
}
}
PLEASE DO COMMENT IN CASE OF ANY DOUBTS.