Write an interactive program to print a string entered in a pyramid form.(Like one given below).12/8/2015 //please save this code as Pattern.java or download the given file and compile it with " javac Pattern.java " //After successful compilation run this with " java Pattern" at CMD // Make sure you have java already //installed in your system . CODE : : import java.util.*; class Pattern { public static void main(String m[]) { char c; int i,j; Scanner in= new Scanner(System.in); String s;//=new String("STREAM"); System.out.println("Enter A String::"); s=in.next(); int k,d; for(i=0;i<s.length();i++) { for(k=0;k<s.length()-i;k++) { System.out.print(" "); } for(j=0;j<=i;j++) { c=s.charAt(j); System.out.print(c+" "); } System.out.println(" "); } } } OUTPUT : :
rajan
12/9/2016 08:05:03 pm
thanks for this programm......
Reply
Your comment will be posted after it is approved.
Leave a Reply. |
Hello friends, i am a CSE student and i am going to upload all the programs of various language which might be in your collage practical list or might help you in performing your practicals in lab. Archives
August 2015
Categories |