Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


bhaskarreddy
DIAMOND PROGRAM 122
1 Answer(s)      4 years and 9 months ago
Posted in : Java Interview Questions



Advertisement
View Answers

November 16, 2009 at 10:24 AM


Hi Friend,

Try the following code:

public class Diamond{
public static void main(String[] args){
int row = 7;
for(int i=1; i<(row/2+.5); i++ ){
for (int j=1; j<(row/2+1.5)-i; j++){
System.out.print(" ");
}
for(int c=0; c<(i*2)-1; c++)
System.out.print("*");
System.out.println();
}
for(int d=1; d<row+1; d++){
System.out.print("*");
}
System.out.println();
for(int i=1; i<(row/2+.5); i++ ){
for(int c=0;c<i; c++)
System.out.print(" ");
for(int j=1; j<row-(i*2)+1; j++){
System.out.print("*");
}
System.out.println();
}

}
}

Thanks


Related Tutorials/Questions & Answers:
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<
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
Advertisements
diamond print
diamond print   print the pattern 1 2 3 4 5 6 7 8 9 10 11 12
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
how to create this diamond structure with java. - Java Beginners
how to create this diamond structure with java.   * *** ***** * *** *** * ***** * *** *** * ***** * *** *** * ***** *** *   
I need to output number diamond using nested for loops.
I need to output number diamond using nested for loops.  How to i output this using nested for loops 1 131 13531 1357531 135797531 1357531 13531 131 1
program
program  any program of hotel or school management
program
program  write a program different between to dates in terms of days in java
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  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
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   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
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = ‚??Tommy‚?? age=‚??23‚?? and call this constructor
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
Java Program - Java Beginners
Java Program  Write a program to input a string and print out... OUTPUT : wELcOMe to sCHOOL Sir, Can we show this program through... to the string buffer. * If the character is between the range 97 to 122 i.e., if its
program calculateCylinderVolume
program calculateCylinderVolume  program calculateCylinderVolume
java program for
java program for   java program for printing documents,images and cards
Magic number Java Program
Magic number Java Program  write a program that guesses what number... 106 107 110 111 114 115 118 119 122 123 126 127 130 131 134 135 138 139 142 143... 121 122 123 124 125 126 127 136 137 138 139 140 141 142 143 152 153 154 155 156
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
string program
string program  write a program to print the pattern p r o program r a m
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
Jsp program
Jsp program  A sample program of jsp using dml quaries
java program
java program  write a program to print 1234 567 89 10
Advertisements
 

 

 

DMCA.com