1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import java.io.*; public class casechange { public static void main()throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); String s, s2=""; int l, i, j; char ch; System.out.println("Enter a string:"); s = r.readLine(); l = s.length(); for(i=0;i<l;i++) { ch = s.charAt(i); if(ch>='A'&&ch<='Z') ch = (char)(ch+32); else if(ch>='a'&&ch<='z') ch = (char)(ch-32); s2+=ch; } System.out.println("Input: "+s); System.out.println("Output: "+s2); } } |
1 2 3 4 5 |
<h3>Output</h3> Enter a string: This Is the COUNtry of INDIA Input: This Is the COUNtry of INDIA Output: tHIS iS THE counTRY OF india |
Leave a Reply
You must be logged in to post a comment.