Friday, 10 January 2014

Java : Change case of the entered string from uppercase to lowercase

public class Ques2 {
/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws IOException {
    //ascii A=65 Z=90 a=97
    System.out.println("Enter UPPERCASE");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   // String input = br.readLine().toLowerCase();
    char c;
    char[] word=br.readLine().toCharArray();
   for(int i :word)
   {
       if(i>=65 && i<=90){
       i=i+32 ;
       c=(char) i;
        System.out.println(c);
       }
       else{
           c=(char)i;
           System.out.println(c);
       }
   }

}
}

No comments:

Post a Comment