मराठी

Write a program for the following. Input a String and change the text given by the user to title case. [avoid using method.toUpperCase()]

Advertisements
Advertisements

प्रश्न

Write a program for the following.

Input a String and change the text given by the user to title case. [avoid using method.toUpperCase()]

कोड लेखन
Advertisements

उत्तर

import java.util.*;
class clTask
{
    void main()
    {
         String s1 = "", s2 = “", s3= "'";
         Scanner sc = new Scanner(System.in);
         char ch1, ch2;
         int count = 0;
         System.out.print(" Enter a sentence : ");
         s1 = sc.nextLine();
         for(int j = 0; j <= s1.length() - 1; j++)
         {
            ch1 = s1.charAt(j);
            if(ch1 >='a' && ch1 <>=,z'(
            {
                 s2 = s2 + (char)(ch1 – 32);
            }
            else
            {
                 s2 = s2 + ch1;
            }
         }
         System.out.println("New string is: " + s2);
    }
}

Output:

Enter a sentence : Independence Day is on 15Aug1947

New string is : INDEPENDENCE DAY IS ON 15AUG1947

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 10: String Handling - Exercises [पृष्ठ २४८]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 10 String Handling
Exercises | Q 3. (f) | पृष्ठ २४८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×