Page 362 - Computer science 868 Class 12
P. 362
21 System.out.println("Changed String:");
22 System.out.print(strl+stru);
23 }
24 }
The output of the preceding program is as follows:
Enter string: Well done boy
Changed String:
elldoneboyW
Changed String:
elldoneboyW
Program 2 Write a program in Java to accept a string. Arrange all the letters of the string in an alphabetical
order. Now, insert the missing letters in the sorted string to complete all the letters between
the first and the last characters of the string.
Sample Input:
computer
Alphabetical order:
cemoprtu
Sample Output:
cdefghijklmnopqrstu
1 import java.util.*;
2 class strprogram2
3 {
4 public static void main()
5 {
6 Scanner sc = new Scanner(System.in);
7 String sortedStr = "",str,filstr = "";
8 int len,j,i;
9 char ch;
10 System.out.println("Enter a string:");
11 str = sc.nextLine();
12 str = str.toLowerCase();
13 len = str.length();
14 for (i = 'a'; i <= 'z'; i++)
15 {
360360 Touchpad Computer Science-XII

