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




Have Programming Question? Ask it here!
 
 
 


Hina Saeed
Shape
1 Answer(s)      6 years and 4 months 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.


Advertisement
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( "" );
}
}
}



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
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
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
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
Show Rotation property of class AffineTransform
property. To show rotation, we have used Ellipse2D class to draw the shape oval...); The method draw(shape) draws the specified shape in the original location defined... for the specified shape has been given by the interface Stroke. To outline
Use Alpha values to draw in Layers
values to the draw the specific shape in layers. An alpha object produces the alpha..., objects are invisible. As the intensity decreases, the specific shape becomes... (350,300) is created. The g.fillOval() fills the oval shape with the color defined
Move Curve Control Point
control point and manipulates the shape of curve. The Control points are the points on a curve which are used to change the shape and angle of the curve. On stretching and rotating the control point, the shape of the curve and the angle
How to design a text button.
How to design a text button.       With this tutorial you will be able to learn a design of the text button, mostly we use simple buttons of circle and rectangle shape
How to Create Circle In Java
. It describes a shape. But the Java 2D definition of a shape does not require the shape to enclose an area. The Java2D API  also provides several classes
Clip of image
. To show the image clip, we have used Ellipse2D class to show the oval shape.... To give the stylistic and impressive outline of the specified shape, class...;private double p, q;   private double ip 
Top 10 Java People You Should Know
are the innovators in applying this language to shape our web and computing experience? Here we
Overview of Web 3.0
a handsome shape. Web 3.0 have some more feature including the feature of Web... rather than now. The looks and shape of the blogging would be also changed
Button in Flex
Button: A Button is usually in rectangular shape and it looks like it can be pressed, it could have a text, an icon, or both. A Button could be a normal button or toggle button. A normal button persists in deselected mode
Help
shape of your choice. The class should contain a constructor, appropriate data fields and methods to return the volume of the shape, and the surface area of the shape and any other methods that seem to make sense for you shape
sahabaj
sahabaj  diamond shape pattern print of numbers 123456789101112131415987654321
hierarchy UML class diag
hierarchy UML class diag   Shape Square Circle Rectangle class Shape { string name; public: Shape(string); virtual void ToString(); virtual void Area()=0; }; class Square : public Shape { double side; public
MEANING OF THe CODE IN BOLD LETTERS
MEANING OF THe CODE IN BOLD LETTERS  public static void main(sting args[]) { shape s[] = {new circle(),new rectangle()}; } //HERE SHAPE RECTANGLE AND CIRCLE ARE THREE CLASSES WHICH ARE DEFINED EARLIER IN THE PROGRAM
How to insert a symbol on the stone
. Insert a Shape: Choose "dcd7db" color and this shape by the Custom shape tool (U key) as looking here. Inset the shape on the new layer. Effect: Select your shape layer and right click to use "Blending
java sample program - Java Beginners
for polymorphism  Hi Friend, Try the following code: class Shape { int x,y; void area(){ } } class Square extends Shape { int l=2; void area() { System.out.println(l*l); } } class Rectangle extends Shape
How to design a simple note book
. New File: Create a new file with appropriate size. Rectangle Shape: Choose Rectangle tool (U key) and make a rectangle shape with this "ECAF8D" color as looking down. Modify Shape: Choose Direct selection tool (U key
How to make a navigation bar
: Take a new file with any size. Rectangle Shape: Choose Rectangle tool (U key) and this color "b2afaf" then draw a rectangle shape. Stroke: Go... will look like this. Rectangle Shape: Choose Rectangle tool and make a shape
How to make a folder icon, make a folder icon, folder icon
size. Rounded Rectangle Shape (U key): Take "f4e21a" color and Rounded rectangle tool to draw a shape then select Direct selection tool (A key) to modify the shape as given here. Effects: Go to Layer Menu > Layer Style
How to draw a television
Shape: First draw a Rectangle shape with black color by using Rectangle tool (U... and Emboss and use both settings. Rectangle Shape: Choose "d3d3d3" color and make a rectangle shape in side the big rectangle shape
How to design a countdown, design a countdown, countdown
a Shape: Select Custom shape tool (U key) and select this shape. Draw a Shape: Now draw this shape on your document. Make a Shape: First take a new layer then draw this shape by using Pen tool (P key) with this color "
Clipping
Clipping   hii, What is clipping?   hii Clipping is the process of confining paint operations to a limited area or shape
Java Variables - Java Beginners
reference variables, and how can i see what a reference variable contains.. shape s = new shape(); Here 'shape' is a class and 's' is an object refernce
Java Variables - Java Beginners
reference variables, and how can i see what a reference variable contains.. shape s = new shape(); Here 'shape' is a class and 's' is an object refernce
How to make an animated navigation bar with css
by this example. Rounded rectangle shape: Draw a rounded rectangle shape by the Rounded rectangle tool (U key). Effects: Go to Layer menu >... it. Rectangle shape: Choose "White" color and draw
java code - Java Beginners
()); } } 2) class Shape{ double pi=3.14; Shape(int side){ System.out.println("Area and Perimeter of Square with side "+ side); } Shape(long length... "+ length+" and breadth "+breadth); } Shape(double radius
square - Java Beginners
square  what is the java code to display the shape of "square"?  Hi friend, Code to display the shape of "square" import... SquareShape extends Frame { Shape square = new Rectangle2D.Double(100, 100,100
How to make a bone, make a bone, a bone
shape: Choose "White" color and Rounded rectangle shape tool (U key) to draw a rounded rectangle shape. Modification: Choose Direct selection
How to design a piano
; color. Now draw a rectangle shape as looking here. Bevel and Emboss... as given below. You will get it. Another Rectangle Shape... and choose Rectangle shape to draw as looking here. Make duplicate layer
for loop
for loop  how to performs the for loop when 2 inputs given like displays the triangle shape and how to take initial values or declaration values plz explain in detailed ex. 1 12 123 1234
C++ Question 2
data members from base class  2.create class. Shape accepts two values... "Shape" to represent two different derived classes Triangle and Rectangle. Each... of relevant shape on the screen and a member function getdata() to initialize base
 

 

 

DMCA.com