Computer Science, asked by spoorthidaffodils, 8 months ago

write a program in java to enter a string.print the string in alphabatical orders of letters. sample input:Computer sample output: Cemoprtu​

Answers

Answered by bhoomika111141
0

Answer:

String str is given which contains lowercase English letters and spaces. It may contain multiple spaces. Get the first letter of every word and return the result as a string. The result should not contain any space.

Examples:

Input : str = "geeks for geeks" Output : gfg Input : str = "happy coding" Output : hc

Answered by amansarrafas24payxgs
0

Answer:

import java.util.*;

class Alphabet

{

public void main()

{

Scanner sc = new Scanner (System.in);

System.out.println("Enter a String: ");

String str = sc.nextLine();

for(int i = 0;i < str.length();i++)

{

char ch = str.charAt(i);

for(int j = 97;j <= 122;j++)

{

if(ch == j(char))

{

System.out.print(ch);

}

}

}

}

}

I hope you find it useful... If you have any query do comment, I will try to solve it...

Similar questions