Java program of Sentence – Convert to upper and lower


Write a program to get a sentence as input. In the first word of the sentence keep the first character as it is and change the remaining to upper case, then in the second word keep the first two characters as it is and change the remaining to upper case. Continue this pattern for the remaining words too.

Sample Input1:

java is a programming language

Sample Output1:

jAVA is a progRAMMING languAGE

Sample Input1:

good programming practice

Sample Output1:



import java.util.*;
public class Main 
    public static void main (String[] args) {
        Scanner sc=new Scanner(;
        String input=sc.nextLine();
        String str[]=input.split(" ");
        int n1=str.length;
        String output=new String();
        for(int i=0;i<n1;i++)
            for(int j=0;j<str[i].length();j++)
            output=output+" ";


  1. Array square
  2. Generate number using odd digits
  3. Alternate Number Difference
  4. Next Greatest number
  5. Mark Comparison
  6. Print the characters in descending order
  7. Vowels in a fishBowl
  8. Least offer
  9. Ascending and descending order
  10. Mail Domain
  11. Count repeating words
  12. Sentence – Convert to upper and lower
  13. Count consecutive repeating characters
  14. Zig zag Array
  15. Pass and Fail Count
  16. Search a Course
  17. Average and Grade Calculation
  18. String – Find and replace the character (first occurrence)
  19. Sort the first and second half of an array
  20. Retail Shop
  21. Palindrome
  22. Numerology
  23. InitCap
  24. Array Compatiblilty
  25. Sum of the maximum and the minimum element
  26. String Concatenation
  27. Find Average Age
  28. Login

Leave a Comment

Your email address will not be published. Required fields are marked *