Programming Examples

Java program to arrange the sentence in alphabetical order of the words


Write  a  program  to  accept  a  sentence as  input.  The  words  in  the  string  are  to   be   separated by a blank.  Each  word  must  be  in  upper  case.  The  sentence  is  terminated  by  either “.”,”!” or “?”. Perform the following tasks:

(i) Obtain the length of the sentence (measured in words).

(ii) Arrange the sentence in alphabetical order of the words.

Example 1

INPUT: NECESSITY IS THE MOTHER OF INVENTION.

OUTPUT:

LENGTH : 6

REARRANGED SENTENCE : INVENTION IS MOTHER NECESSITY OF THE

Example 2

INPUT: BE GOOD TO OTHERS.

OUTPUT:

LENGTH : 4

REARRANGED SENTENCE : BE GOOD OTHERS TO

Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz