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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vincent CWS
shape looping
2 Answer(s)      2 years and 8 months ago
Posted in : Java Beginners


can some1 help me?i have to make a shape using "*" by looping...and i dun know how...please and thank you * **


Advertisement
View Answers

April 17, 2012 at 11:39 AM


java diamond shape:

public class Diamond{
public static void main(String[] args){
int row = 5;
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(c);
System.out.println();
}
for(int d=1; d<row+1; d++){
System.out.print(d);
}
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(j);
}
System.out.println();
}
}
}


April 17, 2012 at 11:40 AM


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


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
looping
looping   sum of the series s=1+2/1*2
Advertisements
looping ..
looping ..  can i get coding for get the following output: (using looping) 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
looping with strings
looping with strings  how to print this w we wel welc welco with loop?   import java.util.*; class StringExample3 { public static void main(String[] args) { Scanner input=new Scanner(System.in
looping structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
looping programm of sum
looping programm of sum  s=1+2/12+1+2+3/12*3+1+2+3+..... n
Flex Looping
.style1 { border-style: solid; border-width: 1px; background-color: #FFFFCC; } Executing a set of statements repeatedly is performed through looping. For this purpose, Flex provides some looping mechanism like: 1
Ask about looping in database
Ask about looping in database  Good afternoon, I want to ask... that how to read looping in field rights(if A1=false and A2 = True), use from java. i want to call rights looping with code program from java. i read from datatase
looping through a list of methods
looping through a list of methods  I have a number of methods that do the almost same thing: public void setColorRed (int colorvalue); public void setColorYellow (int colorvalue); public void setColorBlue (int colorvalue
farbonicci in looping - Spring
farbonicci in looping  how to make a program use farbonicci in looping?  import java.io.*; public class FibonciiExample{ public static void main(String[] args) throws Exception{ System.out.println("Fibonccii
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
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
Mysql Looping
Mysql Looping       Looping in Mysql is a simple loop construct,that enables the repeated.... Understand with Example The Tutorial illustrate an example from 'Mysql Looping
Mysql Looping
Mysql Looping       Looping in Mysql is a simple loop construct, that enables the repeated execution... with Example The Tutorial illustrate an example from 'Mysql Looping'. To understand
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
Looping Statements in java 7
Looping Statements in java 7 In this section, we will discuss about Looping Statements in java 7. This is one type of control flow statement. Looping... of statements repeatedly. Following are three types of Looping statements
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
Unable looping using JOptionPane - Java Beginners
Unable looping using JOptionPane  import javax.swing.*; public class Shop{ public static void main(String [] args){ Shop shop = new Shop(); String mainMenu= "(MAIN SCREEN )"; mainMenu+= "\n1) Computer Menu
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
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement  hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt
Looping In Java Script
Looping In Java Script In this article you learn the basics... a task. JavaScript supported Two different type looping :-  1.The...;/head> </body> </html> Javascript looping
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
 

 

 

DMCA.com