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

Series Programs-5

Program: 11
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))))  || (j<=(0+(i-(11/2)))) || (j>=(9-(i-(11/2)))))
                System.out.print("*");
                else{
                 
                 System.out.print(" ");
                }
            }
            System.out.println("");
        }
     }
}

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

Program 12
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))))  || (j<=(0+(i-(11/2)))) || (j>=(9-(i-(11/2)))))
                System.out.print(" ");
                else{
                 
                 System.out.print("*");
                }
            }
            System.out.println("");
        }
     }
}

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


No comments:

Post a Comment