Shape

Ads

 
 

Share on Google+Share on Google+

Hina Saeed
Shape
1 Answer(s)      9 years ago
Posted in : Java Beginners

Respected Sir, Please send me the code of diamond shape by using loop and with single statement of " " and single statement with "*".  ... for diamond shape.

Ads
View Answers

April 9, 2008 at 6:02 PM


Hi friend

I understand your problem, so that I am sending you coding for diamond shape.
Please let me know for further help.
Hope it will help u.

import java.io.*;
import java.io.BufferedReader;

public class PrintDiamond{
public static final void main(String[] args) throws IOException{
BufferedReader read = new BufferedReader( new InputStreamReader(System.in));
System.out.print("Enter the numerical Numebr:");
String str= read.readLine();
int n = Integer.parseInt(str);
for ( int i = 1; i <= n; i += 2 ){
for(int k = 0; k < ( n - i ); k += 2)
System.out.print(" ");
for(int j = 0; j < ( ( i * 2 ) - 1 ); j += 2)
System.out.print("*");
System.out.println("");
}
for(int i = 1; i <= n; i += 2){
for(int k = 1; k < i; k += 2)
System.out.print(" ");
for(int j = 0; j <= (n - i); j++)
System.out.print("*");
System.out.println( "" );
}
}
}


Ads









Related Tutorials/Questions & Answers:
shape looping
shape looping  can some1 help me?i have to make a shape using "*" by looping...and i dun know how...please and thank you * **   java diamond shape: public class Diamond{ public static void main(String[] args){ int
How to convert a picture into a shape, convert a picture into a shape, picture shape
How to convert a picture into a shape       If you want to use a picture shape but you are not able for that, don't worry. You will learn easily to convert a picture into shape. Take
Advertisements
Shape - Java Beginners
Shape  Respected Sir, Please send me the code of diamond shape by using loop and with single statement of " " and single statement with "*".  ... for diamond shape.   Hi friend I understand your problem, so that I
Version of ca.seinesoftware>xml-shape dependency
List of Version of ca.seinesoftware>xml-shape dependency
How to convert new paper into a man shape, convert new paper into a man shape, new paper into a man shape
How to convert new paper into a man shape   ... shape in this example. Take a new picture: Take a news paper picture, choose Polygonal lasso tool (L key) to make selection like a man shape
Version of com.shapesecurity>shape-functional-java dependency
List of Version of com.shapesecurity>shape-functional-java dependency
Maven Dependency xml-shape >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of ca.seinesoftware >> xml-shape version1.0.0 in your project
Drawing a Shape in Excel Sheet
Drawing a Shape in Excel Sheet In this section, you will learn how to draw a shape in excel sheets using Apache POI library. Using Apache POI, you can draw a shape with the help of Microsoft Office drawing tools. The top-most shape
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
Create Shape in Excel Using JSP
create shape in excel using jsp    ...; and then after we create a shape. At excel sheet e.g. we are creating line in this example. To create shape we use setShapeType() in this method we are passing
Maven Dependency shape-functional-java >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version1.0.1 in your project
Maven Dependency shape-functional-java >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version1.1.0 in your project
Maven Dependency shape-functional-java >> 2.0.2
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version2.0.2 in your project
Maven Dependency shape-functional-java >> 2.3.1
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version2.3.1 in your project
Maven Dependency shape-functional-java >> 1.0.2
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version1.0.2 in your project
Maven Dependency shape-functional-java >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version1.0.3 in your project
Maven Dependency shape-functional-java >> 2.0.0
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version2.0.0 in your project
Maven Dependency shape-functional-java >> 2.0.1
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version2.0.1 in your project
Maven Dependency shape-functional-java >> 2.1.0
You should include the dependency code given in this page to add Maven Dependency of com.shapesecurity >> shape-functional-java version2.1.0 in your project
Creating Auto Shape in PowerPoint Using Java
Creating Auto Shape in PowerPoint Using Java... to create auto shape on PowerPoint slide using java. In this example, we are creating the object of AutoShape .We are passing the shape type into AutoShape
Inserting Text on Shape Using Java
Inserting Text on Shape Using Java       In this example we are going to create auto shape... the object of AutoShape .We are passing the shape type into AutoShape as argument
four rectangle/image of the shape of the button.then Draw these on some x and y co-ordinated in j2me then how to draw ?
four rectangle/image of the shape of the button.then Draw these on some x and y co-ordinated in j2me then how to draw ?  hi, i have button use... of the shape of the button.then Draw these on some x and y co-ordinated in j2me
Create cube shape in Applet
Create cube shape in Applet In this tutorial, you will learn how to create a cube using java2d. The example creates a cube which gives a 3d view to the cube. Here we haven't used java3d packages. The cube can be rotate when
Creating Shapes using Shape Groups
Creating Shapes using Shape Groups In this section, you will learn how to create shapes using Apache POI library. EXAMPLE import... = (HSSFPatriarch) sheet .createDrawingPatriarch(); // Create a shape group
Create Round Button in Java swing
a button of round shape. Java2D APIs and Java Swing make it easy to implement..., then add code to set the shape you want to give. Finally override the paintComponent() and paintBorder() methods to render the shape. Example: import
Java create triangle pattern
Java create triangle pattern In this tutorial, you will learn how to create a triangle shape. For this, user is allowed to enter number of lines to display the triangle of that length and a symbol to show the triangle in a particular
Simple Basic Stroke Example
stroke.  The stylistic representation of the outline for the specified shape has been given by the interface Stroke. To outline the specified shape rendered... the shape. The float value pass into the constructor of class BasicStroke shows
Write a program to construct a triangle with the ?*?
programming will teach you the coding for constructing a shape of triangle by using... any number on your command window and surely you will get a triangle shape