Saturday, 23 July 2016

Q.3 Change letters of the entered string from Uppercase to Lowercase and vice versa 
import java.util.Scanner;

public class ReverseCase {

public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter a String");
String s=sc.next(); 
char ch[]=s.toCharArray();
for(int i=0;i<ch.length;i++){
if(ch[i]<90){
ch[i]=(char) (ch[i]+32);
}
else{
ch[i]=(char) (ch[i]-32);
}
}
System.out.println(ch);

}
}

No comments:

Post a Comment

Featured post

All Logical Questions are Answered JumpInToIt