Are You Feeling any difficulity while writing Core-Java Programs. Send those to me Here.

Series Programs-3

Program: 7
public class HelloWorld{
     public static void main(String []args){
        for(int i=19;i>0;i-=2){
            for(int k=i;k<20;k+=2)
            System.out.print(" ");
            for(int j=0;j<i;j++){
                System.out.print("*");
            }
            System.out.println("");
        }
     }
}

Output:
*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
    *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
        *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
            *  *  *  *  *  *  *  *  *  *  *  *  *
                *  *  *  *  *  *  *  *  *  *  *
                    *  *  *  *  *  *  *  *  *
                        *  *  *  *  *  *  *
                            *  *  *  *  *
                                *  *  *
                                    *

Program: 8

public class HelloWorld{
     public static void main(String []args){
        for(int i=0;i<11;i++){
            for(int j=0;j<10;j++){
                if((j<(0+((11/2)-(i)))) || (j>=(11-((11/2)-(i-1)))))
                System.out.print("*");
                else
                System.out.print(" ");
            }
            System.out.println("");
        }
   }
}
Output:
*  *  *  *  *  *  *  *  *  *
*  *  *  *          *  *  *  *
*  *  *                  *  *  *
*  *                          *  *
*                                  *



No comments:

Post a Comment