मराठी

Write a program for the following. Input a string and print the characters that are not alphabets followed by the alphabets in it.

Advertisements
Advertisements

प्रश्न

Write a program for the following.

Input a string and print the characters that are not alphabets followed by the alphabets in it.

कोड लेखन
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' || ch1='a' && chl<='7(
        {
            s2 = s2 + ch1;
       }
       else
       {
            s3 = s3 + ch1;
        }
     }
     s3 = s3 + s2;
     System.out.println("New String is: "+ s3);
    }
}

Output:

Enter a sentence : MHBLP,68/5,LANE#3,KONKAN

New String is :,68/5,#3,MHBLPLANEKONKAN

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

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×