Program to Convert Input String to UPPERCASE
import java.util.Scanner; class LC { public static void main(String[] args) { System.out.println("Enter a String : "); Scanner sc = new Scanner(System.in); String s = sc.next(); String result=""; for(int i=0 ; i< s.length() ; i++) { Character c= s.charAt(i); if(Character.isLowerCase(c)) { Character newChar=Character.toUpperCase(c); result=result.concat(Character.toString(newChar)); } // if end else { result=result.concat(Character.toString(c)); } // else end } //for end System.out.println("You entered "+s); System.out.println("Result is "+result); } }
No comments:
Post a Comment