Java program to display following pattern
OUTPUT |
import java.util.Scanner;
public class demo{
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
StringBuffer sb = new StringBuffer(sc.next());
sc.close();
for(int i=0;i<sb.length();i++){
char ch = (char)(sb.charAt(0)+32);
sb.replace(0, sb.length()-1, sb.substring(1,sb.length()));
sb.replace(sb.length()-1,sb.length(),new String(ch+""));
if(!Character.isUpperCase(sb.charAt(0))){
ch = (char)(sb.charAt(0)-32);
sb.delete(0,1);
sb = new StringBuffer(new String(ch+"") + sb);
}
System.out.println(sb);
}
}
}
Comments
Post a Comment