Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program called StringMethods that reads from the user two strings (

ID: 3757691 • Letter: W

Question

Write a java program called StringMethods that reads from the user two strings (name them string_1 and string_2), and then uses String class methods to manipulate these strings as follows:

Determine the length of string_1.

Determine the length of string_2.

Concatenate both strings.

Check if the two strings have same set of characters with regard to case (i.e., equal).

Convert string_1 to upper case.

Convert string_2 to lower case.

Extract a valid substring of multiple characters from string_1. The number of characters in your substring is up to you, but it should be greater than zero and less than the length of the string.

Make sure to properly label your output for each manipulation and print the outputs on separate lines. Use the tab escape character to line-up the outputs after the labels as follows:

Furthermore, separate your code into sections with proper in-line comments such as:

Explanation / Answer

If you need any further modification, just ping me.

import java.util.Scanner;
class StringManipulation
{
public static void main(String[] args)
{
String string_1, string_2;
Scanner sc = new Scanner(System.in);
//Reads first string.
System.out.print("Enter the first string: ");
string_1 = sc.next();
//Reads second string.
System.out.print("Enter the second string: ");
string_2 = sc.next();
//Prints the length of each string.
System.out.println("Length of string _1: "+string_1.length());
System.out.println("Length of string _2: "+string_2.length());
//Concatenates two strings.
String string_3 = string_1 + string_2;
System.out.println("After concatenation: "+string_3);
//Checks the equality of two strings.
if(string_1.compareTo(string_2) == 0)
System.out.println("Equality of strings: YES.");
else
System.out.println("Equality of strings: NO.");
//Converts the strings to uppercase, and displays.
System.out.println("string_1 in UpperCase: "+string_1.toUpperCase());
System.out.println("string_2 in UpperCase: "+string_2.toUpperCase());
//Extracts a substring from string_1 and displays.
int x = string_1.length();
System.out.println("The substring of string_1 :"+(string_1.substring(2,x)));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote