Sunday, 7 June 2015

JAVA



Sample Input: MY NAME IS SAYAM BANDYOPADHYAY
Sample Output: My Name Is Sayam Bandyopadhyay


just see it ......
my comp teacher told it is wrong......
import java.util.*;
class s
{
    public static void main(String []args)
    {
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a line in capital letterzzz");
        String st=sc.nextLine();
        st=" "+st.toLowerCase();
        String st1=" " ;
        char ch= ' ';
        int l=st.length();
        for (int i=0;i<l-1;i++)
        {
            ch=st.charAt(i);
            if(ch==' ')
            {
                st1=st1+Character.toUpperCase(st.charAt(i+1));                                    
            }
            else
            st1=st1+st.charAt(i+1);
        }
        System.out.println(st1.trim());
    }
}
 if any one tells that its wrong please post the right one please sake of ICSE

                

No comments:

Post a Comment