Q.3 Change letters of the entered string from Uppercase to Lowercase and vice versaimport 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