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

Series Programs-4

Program: 9
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:
                *  *
            *  *  *  *
        *  *  *  *  *  *
    *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *  *

Program: 10
public class HelloWorld{
     public static void main(String []args){
        for(int i=11;i>=0;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