Computer Science, asked by nirmalavshetty1, 7 hours ago

Aim: To manipulate string functions
Write a program in java to accept a word or string by using scanner class and find to manipulate any 5 string functions and complete the program.​

Answers

Answered by PranathP
2

Answer:

import java.util.Scanner;

class wordmanipulation

{

public static void main (String args[])

{

Scanner sc = new Scanner (System.in);

System.out.println("Enter a word.");

String word;

word = sc.nextLine();

System.out.println("Entered word:" + word);

word = word.toUpperCase();

System.out.println("Upper Case: " + word);

word = word.toLowerCase();

System.out.println("Lower Case: " + word);

String sub = word.substring(2);

System.out.println("Substring (index 2) : " + sub);

System.out.println("Enter Another word.");

String word2;

word2 = sc.nextLine();

System.out.println("Entered new word is: " + word2);

String con = word.concat(word2);

System.out.println("Concatenated String is: " + con);

System.out.println("Length of first string entered: " + word.length());

}

}

Refer to the attachment for the output.

Attachments:
Similar questions