how to create this diamond structure with java.

how to create this diamond structure with java.

*
***
***** *
*** ***
* ***** *
*** ***
* ***** *
*** ***
* *****
***
*
View Answers

January 23, 2010 at 4:53 PM

Hi Friend,

Try the following code:

class Stars{
public static void main(String []args){
for(int i=1;i<=5;i+=2){
System.out.println("");
for(int j=1;j<=i;j++)
System.out.print("*");
}
System.out.print(" *");
System.out.println();
for(int k=1;k<=2;k++){
for(int l=1;l<=3;l++){
System.out.print("*");
}
System.out.print(" ");
}
System.out.println();
for(int i=1;i<=2;i++){
System.out.print("*");
System.out.print(" ");
for(int j=1;j<=5;j++){
System.out.print("*");
}
System.out.println(" *");

for(int k=1;k<=2;k++){
for(int l=1;l<=3;l++){
System.out.print("*");
}
System.out.print(" ");
}
System.out.println();
}
System.out.print("* ");
for(int i=5;i>=0;i-=2){
for(int j=0;j<i;j++){
System.out.print("*");
}
System.out.println();
}
}
}

Thanks









Related Tutorials/Questions & Answers:
how to create this diamond structure with java. - Java Beginners
how to create this diamond structure with java.   * *** ***** * *** *** * ***** * *** *** * ***** * *** *** * ***** *** *   
how to create this structure in json using grails
how to create this structure in json using grails  { "query": { "type": "cluster", "view": "accountActivity", "regions": [2342,334,241,13], "companies": [43228583,433421683,342427783], "departments": [1,2,4,6], "brands
Advertisements
How to make a diamond necklace, make a diamond necklace, diamond necklace
How to make a diamond necklace       This tutorial will give you instruction to make draw a diamond necklace, so follow all the steps to make similar. New file: First take a new
why to create directory structure as web-inf & classes & lib - Java Beginners
why to create directory structure as web-inf & classes & lib    we all know that to prepare webapplications we will create a direcotry sturcture... actually what is the reason behind this creating this directory structure
why to create directory structure as web-inf & classes & lib - Java Beginners
why to create directory structure as web-inf & classes & lib    we all know that to prepare webapplications we will create a direcotry sturcture... actually what is the reason behind this creating this directory structure
Draw a diamond - Java Beginners
Draw a diamond  I want to draw a diamond shapein java using (*) in 9 lines. Here is the code import java.util.*; public class Diamond { static... the problem : import java.util.*; public class Diamond { static Scanner
Diamond - Java Beginners
Break out of if statement java  Hi, please explain how to break out of if statement in Java?  Hi Friend,public class PrintExam{ public static void main(String[] args){ int i; int j; for(i=1; i<7; i++){ for(j=0
DIAMOND PROGRAM - Java Interview Questions
DIAMOND PROGRAM  I Want Print Diamond ?I Want Code?plz help me  Hi Friend, Try the following code: public class PrintDiamond { public static void main(String[] args) { int n = 5; for (int i = -n
Diamond shape num - Java Interview Questions
Diamond shape num  How To Print Diamond Shape Numbers I Want Logic?Using For loops?  Hi Friend, Try the following code: public class Diamond{ public static void main(String[] args){ int row = 5; for(int i=1
ARRAY DIAMOND - Java Interview Questions
ARRAY DIAMOND  HI I WANT PRINT LIKE THIS I Want Print In Diamond Shape? 1 2 3 4 5 6 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 I WANT SOURCE CODE?  Hi Friend, Try the following code: class
how to create notepad in java
how to create notepad in java  how to create notepad in java
How to create a class in java
How to create a class in java  I am a beginner in programming and tried to learn how to do programming in Java. Friends please explain how can I create a class in Java
How to create charts in Java?
How to create charts in Java?  Is there any example of creating charts and graphs in Java? thanks   Hi, check the tutorial: Chart & Graphs Tutorials in Java Thanks
How to Create Keyboard in JAVA
How to Create Keyboard in JAVA  please help me to create On-Screen Keyboard with java and please give me an another idia to make it ..............iam waiting for your help ,think u so much
how to create interfaces in java
how to create interfaces in java  HI, Here is my code public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { public void update() { //code
DIAMOND PROGRAM 122 - Java Interview Questions
DIAMOND PROGRAM 122  I Want Print Exact Diamond Shape?I Want Code ?Plz Help Me?  Hi Friend, Try the following code: public class Diamond{ public static void main(String[] args){ int row = 7; for(int i=1; i<
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
How to create first program in Java?
How to create first program in Java?  Hi, I am new in Java programming. Tell me How to create first program in Java? Thanks   Hi, Read more at First Java Program. Thanks
ModuleNotFoundError: No module named 'diamond'
'diamond' How to remove the ModuleNotFoundError: No module named 'diamond...ModuleNotFoundError: No module named 'diamond'  Hi, My Python... to install padas library. You can install diamond python with following command
ModuleNotFoundError: No module named 'diamond'
'diamond' How to remove the ModuleNotFoundError: No module named 'diamond...ModuleNotFoundError: No module named 'diamond'  Hi, My Python... to install padas library. You can install diamond python with following command
ModuleNotFoundError: No module named 'diamond'
'diamond' How to remove the ModuleNotFoundError: No module named 'diamond...ModuleNotFoundError: No module named 'diamond'  Hi, My Python... to install padas library. You can install diamond python with following command
How to create and use Array in Java?
How to create and use Array in Java?  Hi, How to create and use Array in Java? Write program to construct and use the array. Thanks   Hi... can read complete example at Array in Java. Thanks
How to create first Java Program?
How to create first Java Program?  Hi, I am beginner and I want to write first Java program. How I can setup my machine and write first Java program... and run first Java program: Create program in Note pad: Step 1: Open
how to create executable - Java Beginners
how to create executable  How do i create a executable file from a java file thnks in adv...!  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class CreateExe { public
how create package of this java code
how create package of this java code  Hi,i have email code in java which is working fine with out making package but when i want to make package of this code its stop working.Its showing exception while I execute it.I have to use
how create package of this java code
how create package of this java code  Hi,i have email code in java which is working fine with out making package but when i want to make package of this code its stop working.Its showing exception while I execute it.I have to use
plzz tell me java code for that diamond
plzz tell me java code for that diamond   1 131 13531 1357531 13531 131 1
What is a Loose Diamond?
work with diamonds and create true works of art for the perfect diamond. Now... the diamond and how the loose diamond reflects light and how it allows it to pass...What is a Loose Diamond? Everyone knows what diamonds. Looking at them from
How to create custom exception in Java?
How to create custom exception in Java? In this tutorial we are going to create our own exception class and you will learn the steps to create custom exception class. Custom exceptions are used by Java developers to create
structure in JSP
structure in JSP  How do I achieve structure in JAVA or JSp
ModuleNotFoundError: No module named 'diamond-accounting'
named 'diamond-accounting' How to remove the ModuleNotFoundError: No module named 'diamond-accounting' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'diamond-accounting'  Hi, My
ModuleNotFoundError: No module named 'diamond-patterns'
named 'diamond-patterns' How to remove the ModuleNotFoundError: No module named 'diamond-patterns' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'diamond-patterns'  Hi, My
ModuleNotFoundError: No module named 'appenlight-diamond'
named 'appenlight-diamond' How to remove the ModuleNotFoundError: No module named 'appenlight-diamond' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'appenlight-diamond'  Hi, My
ModuleNotFoundError: No module named 'diamond-next'
'diamond-next' How to remove the ModuleNotFoundError: No module named 'diamond-next' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'diamond-next'  Hi, My Python
ModuleNotFoundError: No module named 'diamond-next'
'diamond-next' How to remove the ModuleNotFoundError: No module named 'diamond-next' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'diamond-next'  Hi, My Python
ModuleNotFoundError: No module named 'diamond-patterns'
named 'diamond-patterns' How to remove the ModuleNotFoundError: No module named 'diamond-patterns' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'diamond-patterns'  Hi, My
ModuleNotFoundError: No module named 'Flask-Diamond'
'Flask-Diamond' How to remove the ModuleNotFoundError: No module named 'Flask-Diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'Flask-Diamond'  Hi, My
ModuleNotFoundError: No module named 'Puppet-Diamond'
named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named 'Puppet-Diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My
ModuleNotFoundError: No module named 'Puppet-Diamond'
named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named 'Puppet-Diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My
ModuleNotFoundError: No module named 'Puppet-Diamond'
named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named 'Puppet-Diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My
ModuleNotFoundError: No module named 'Puppet-Diamond'
named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named 'Puppet-Diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My
ModuleNotFoundError: No module named 'pytest-diamond'
named 'pytest-diamond' How to remove the ModuleNotFoundError: No module named 'pytest-diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'pytest-diamond'  Hi, My
ModuleNotFoundError: No module named 'sf-diamond'
'sf-diamond' How to remove the ModuleNotFoundError: No module named 'sf-diamond' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'sf-diamond'  Hi, My Python
ModuleNotFoundError: No module named 'spud-diamond'
'spud-diamond' How to remove the ModuleNotFoundError: No module named 'spud-diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'spud-diamond'  Hi, My Python
ModuleNotFoundError: No module named 'whale-diamond'
'whale-diamond' How to remove the ModuleNotFoundError: No module named 'whale-diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'whale-diamond'  Hi, My
ModuleNotFoundError: No module named 'whale-diamond'
'whale-diamond' How to remove the ModuleNotFoundError: No module named 'whale-diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'whale-diamond'  Hi, My
ModuleNotFoundError: No module named 'Agile-Diamond'
'Agile-Diamond' How to remove the ModuleNotFoundError: No module named 'Agile-Diamond' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'Agile-Diamond'  Hi, My
ModuleNotFoundError: No module named 'appenlight-diamond'
named 'appenlight-diamond' How to remove the ModuleNotFoundError: No module named 'appenlight-diamond' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'appenlight-diamond'  Hi, My
ModuleNotFoundError: No module named 'diamond-accounting'
named 'diamond-accounting' How to remove the ModuleNotFoundError: No module named 'diamond-accounting' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'diamond-accounting'  Hi, My
ModuleNotFoundError: No module named 'diamond-next'
'diamond-next' How to remove the ModuleNotFoundError: No module named 'diamond-next' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'diamond-next'  Hi, My Python

Ads