Sponsered Links
Categories
Sponsered Links

Write a program to write a pattern like diamond

Write a program to write a pattern like diamond.

                                                           *
                                             * * *
                                            * * * *
                                             * * *
                                                *

public class SIX{

    public static void main(String[] args) {
        for(int x=1;  x<=3; x++)  {
            for(int y=3; y>x; y--)   {
                System.out.print(" "); 
            }
            for(int z=1; z<=x; z++)   {
                System.out.print("*"); 
            }
            for(int z=1; z<x; z++)   {
                System.out.print("*"); 
            }
            System.out.println();
        } 
        for(int x=1;  x<=2; x++)  {
            for(int y=1; y<=x; y++)   {
                System.out.print(" ");
            }  
            for(int z=2; z>=x; z--)   {
                System.out.print("*"); 
            }
            for(int z=2; z>x; z--)   {
                System.out.print("*"); 
            } 
            System.out.println();
        }
    }
}                           

Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved