DIAMOND PROGRAM

DIAMOND PROGRAM

View Answers

November 13, 2009 at 10:50 AM

Hi Friend,

Try the following code:


public class PrintDiamond {
public static void main(String[] args) {
int n = 5;
for (int i = -n; i <= n; i++) {
for (int j = -n; j <= n; j++) {
if (Math.abs(i) + Math.abs(j) <= n){
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
}

Thanks









Related Tutorials/Questions & Answers:
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 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<
Advertisements
ModuleNotFoundError: No module named 'diamond'
ModuleNotFoundError: No module named 'diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond' How to remove the ModuleNotFoundError: No module named 'diamond
ModuleNotFoundError: No module named 'diamond'
ModuleNotFoundError: No module named 'diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond' How to remove the ModuleNotFoundError: No module named 'diamond
ModuleNotFoundError: No module named 'diamond'
ModuleNotFoundError: No module named 'diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond' How to remove the ModuleNotFoundError: No module named 'diamond
ModuleNotFoundError: No module named 'appenlight-diamond'
ModuleNotFoundError: No module named 'appenlight-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'appenlight-diamond' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'diamond-accounting'
ModuleNotFoundError: No module named 'diamond-accounting'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-accounting' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'diamond-next'
ModuleNotFoundError: No module named 'diamond-next'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-next' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'diamond-next'
ModuleNotFoundError: No module named 'diamond-next'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-next' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'diamond-patterns'
ModuleNotFoundError: No module named 'diamond-patterns'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-patterns' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'diamond-patterns'
ModuleNotFoundError: No module named 'diamond-patterns'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-patterns' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'Flask-Diamond'
ModuleNotFoundError: No module named 'Flask-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Flask-Diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Puppet-Diamond'
ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Puppet-Diamond'
ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Puppet-Diamond'
ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Puppet-Diamond'
ModuleNotFoundError: No module named 'Puppet-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Puppet-Diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'pytest-diamond'
ModuleNotFoundError: No module named 'pytest-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pytest-diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'sf-diamond'
ModuleNotFoundError: No module named 'sf-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'sf-diamond' How to remove the ModuleNotFoundError: No module named 'sf
ModuleNotFoundError: No module named 'spud-diamond'
ModuleNotFoundError: No module named 'spud-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'spud-diamond' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'whale-diamond'
ModuleNotFoundError: No module named 'whale-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'whale-diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'whale-diamond'
ModuleNotFoundError: No module named 'whale-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'whale-diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Agile-Diamond'
ModuleNotFoundError: No module named 'Agile-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Agile-Diamond' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'appenlight-diamond'
ModuleNotFoundError: No module named 'appenlight-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'appenlight-diamond' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'diamond-accounting'
ModuleNotFoundError: No module named 'diamond-accounting'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-accounting' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'diamond-next'
ModuleNotFoundError: No module named 'diamond-next'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-next' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'diamond-patterns'
ModuleNotFoundError: No module named 'diamond-patterns'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-patterns' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'Flask-Diamond'
ModuleNotFoundError: No module named 'Flask-Diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Flask-Diamond' How to remove the ModuleNotFoundError: No module named
diamond print
diamond print   print the pattern 1 2 3 4 5 6 7 8 9 10 11 12
ModuleNotFoundError: No module named 'diamond-add-taxonomy'
ModuleNotFoundError: No module named 'diamond-add-taxonomy'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-add-taxonomy' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'diamond-add-taxonomy'
ModuleNotFoundError: No module named 'diamond-add-taxonomy'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-add-taxonomy' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'snap-plugin-collector-diamond'
ModuleNotFoundError: No module named 'snap-plugin-collector-diamond'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'snap-plugin-collector-diamond' How to remove
ModuleNotFoundError: No module named 'cloudify-diamond-plugin'
ModuleNotFoundError: No module named 'cloudify-diamond-plugin'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'cloudify-diamond-plugin' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'diamond-add-taxonomy'
ModuleNotFoundError: No module named 'diamond-add-taxonomy'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'diamond-add-taxonomy' How to remove the ModuleNotFoundError
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
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
Diamond Jewelry
Diamond Jewelry Everyone loves diamonds, especially ladies, because besides... a lot more comfortable in special situations. Basically, diamond jewelry... the cheapest diamond jewelry items, you are making a statement. Don't get us
What is a Loose Diamond?
What is a Loose Diamond? Everyone knows what diamonds. Looking at them from... precious metals. So you know what diamonds are, but what is a loose diamond? A loose diamond is virtually the same, but it has not been used in any piece
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
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
Fashion Diamond Accessories
Fashion Diamond Accessories Fashion diamond accessories come in many different... it is often difficult and time consuming to purchase fashion diamond accessories... that fashion diamond accessories cost a lot of money because of the diamonds
program
program  any program of hotel or school management
program
program  write a javascript program to create a application form with validation
program
program  program of jdbc using ms access for creating table
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes

Ads