Home Answers Viewqa Java-Beginners drawing a christmas tree

 
 


goodie
drawing a christmas tree
1 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

how do i write a program that draws a chrimas tree using the knowledge of loops only. i.e * *** ***** ******* the program will draw a Christ mas tree

View Answers

April 4, 2008 at 6:02 PM


Hi


ChristmasTree.java

import java.awt.*;
import java.lang.*;
import java.io.*;
import java.util.*;

public class ChristmasTree{
public static void main(String arg[]) {
int width=1;

for (int i=0; i <= 5 ; i++) {
for (int x=0; x<=4; x++) {
for (int y=1; y<=width; y++) {
double Number=Math.random()*10;
double Ornament=Math.round(Number);
if (Ornament<=1) {
System.out.print("O");
}
if (Ornament>=2){
System.out.print("X");
}
}
System.out.println("");
width=width+1;
}
width=width-2;
}
}
}









Related Pages:
drawing a christmas tree - Java Beginners
drawing a christmas tree  how do i write a program that draws a chrimas tree using the knowledge of loops only. i.e * *** ***** ******* the program will draw a Christ mas tree  Hi ChristmasTree.javaimport java.awt.
Latitude and Longitude of Christmas Island
Latitude and Longitude of Christmas Island  Hi, What is the Latitude and Longitude on Christmas Island? Thanks   Hi, Latitude of Christmas Island is:-10.5 and Longitude of Christmas Island is: 105.6667 Discovered
Tree
Tree  print("code sample");1) Write Java code to create the following tree using new Tree state- ments: 1
Drawing
the basis for drawing simple graphics (lines, circles, text, ...). It is easy to use, and can be used with the Color class to set the drawing color and Font class to set the font for drawing text. Additional graphical classes In Java 2
How many types of drawing objects are available in drawing toolbar
How many types of drawing objects are available in drawing toolbar  How many types of drawing objects are available in drawing toolbar
Drawing Graphs - Swing AWT
Drawing Graphs  hi i am doing a small project in java swings . there is a database table having two columns A,B i want to plot a graph to that values in database the graph must be interactive graph
tree view
tree view  display a tree view in flex?nodes will be in the form
Drawing Graphs - Java3D
Drawing Graphs  how to draw graphs using certain parameters  Hi Friend, To draw a graph using JfreeChart library, please visit the following link: http://www.roseindia.net/chartgraphs/index.shtml Here you
scrolling a drawing..... - Swing AWT
scrolling a drawing.....  I am using a canvas along with other components like JTable over a frame the drawing which i am going to show over canvas is dynamic and hence there is no fixed size, that's why i need to make
drawing out of bounds
drawing out of bounds  How to throw an exception when a rectangle goes out of the boundaries of a JFrame. The program is asking to draw a triangle, and resize it. If the triagle size goes out of the JFrame throw an execption. I
Spanning Tree
Spanning Tree  hii, What is a spanning Tree?   hello, A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so
binary tree
binary tree  how to count no. of nodes in a binary tree for mlm if it complet tree or incomplet tree in php using mysql db
How to convert a picture to drawing, convert a picture to drawing, picture to drawing
How to convert a picture to drawing       Learn here a simple processing to make a color picture to drawing, we have tried here to take simple step to learn easily for the beginners
Please help in drawing Flowchart
Please help in drawing Flowchart  we found that the student names with marks in a text file the marks decreases significantly. when exams conducted fast 4 times.THe first column is the student name and the second column is marks
drawing shapes in applet - Applet
drawing shapes in applet  hi, i need a single applet prgm which draws cone,cube and square in circle.  Hi manju, This is cube example import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import
Binary tree
Binary tree  hii, What is binary tree?   hello, A binary tree is a tree in which every node has exactly two links i.e left and right link
Binary tree
Binary tree  a. Construct a method to implement a binary tree using an array. b. Implement the binary tree to store numbers in sorted order
binary tree
binary tree  can a binary tree be implemented with out comparing...://www.roseindia.net/java/java-get-example/java-binary-tree-code.shtml http://www.roseindia.net/java/java-get-example/java-binary-tree-insert.shtml
Nitobi Tree
Nitobi Tree       Nitobi Tree Nitobi Tree, the Ajax component of User Interface Suite is used... coding and effort. Nitobi Tree adds just like folder view in Windows
FLex Tree
FLex Tree  I want to change the node name in flex tree my code is: Company:XML = <Element name ="Element" code="400"> <{newChild} name ={newChild1} code="400"/> ; where comapny is dataprovide for tree. I want
tree in java
tree in java  Can you help me to draw the tree? First we assign the parent node. when child node(x) come we must check the condition. there are three condition such as x<5,5<=x<10 and 10<=x<15 after that we have
tree in java
tree in java  Can you help me to draw the tree? First we assign the parent node. when child node(x) come we must check the condition. there are three... average of children. Like following tree. (3+7+12)/3=7(root
tree in java
tree in java  Can you help me to draw the tree? First we assign the parent node. when child node(x) come we must check the condition. there are three... average of children. Like following tree. (3+7+12)/3=7(root
tree in java
tree in java  Can you help me to draw the tree? First we assign the parent node. when child node(x) come we must check the condition. there are three... average of children. Like following tree. (3+7+12)/3=7(root
How to design a tree, design a tree, a tree
How to design a tree       Be alert to learn a simple technique to make a tree example... as you need. Tree: Choose this "4c2228" color and Pen Tool (P key
Tree in flex
Tree in flex  Hi.... Why ismyTreeNode.label or myTreeNode.attributes.label undefined? Can you solve this problem..... Thanks   Ans: Make sure you use the TreeDataProvider methods to modify a node, don't rely
Tree in flex
Tree in flex  Hi........ myTree appears just fine but why can't I access the node attributes? Please provide the solution of that prob.... Thanks  Ans: To access the attributes of the node, use
drawing a human in java - Java Beginners
drawing a human in java  i wanna to draw a human in java can u help me how can i draw.? the question is : how to draw a human in java add the nose + the eye + mouth .   where is the answer.? plz i want
An Applet program for Drawing picture & graph - Applet
An Applet program for Drawing picture & graph  How can I write an Applet program for drawing picture and graph having various colours and tools provided
Decision tree to RDF
Decision tree to RDF  How do we process a decision tree in java and obtain an RDF file of the decision tree
problem in scrolling SVG drawing in canvas - MobileApplications
problem in scrolling SVG drawing in canvas  hi all, i'm developing an app that display maps on mobile -i used SVG graphics in drawing the maps... over the drawing , scrolling works well in wireless toolkit emulator , but when i
Dojo Tree
Dojo Tree          In this section, you will learn about Dojo Tree widget. We will explain you how to create Tree control using Dojo Tree Widget.  Test the sample online
Mlm tree structure
Mlm tree structure  i want mlm tree structure code in php with jquery or Ajax
Mlm tree structure
Mlm tree structure  i want mlm tree structure code in php with jquery or Ajax
Mlm tree structure
Mlm tree structure  i want mlm tree structure code in php with jquery or Ajax
MLM tree structure
MLM tree structure  i want mlm tree structure code in php .Please help me..... thanks in advance
Applet program for drawing picture and graph - Applet
Applet program for drawing picture and graph  Please send me the program(code) of drawing picture and graph in Applet.  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java
Java: Example - Drawing a Face - v2
Java: Example - Drawing a Face - v2 This simple application creates... the paintComponent method to do the drawing. 1 2 3 4 5 6 7 8...()); // Put drawing in window. window.pack(); // Adjust
Java: Example - Drawing a Face - v3
Java: Example - Drawing a Face - v3 Two separate source files This is the same as the previous application, except that the two classes have been put...); window.setContentPane(new Face()); // Put drawing in window
Dojo Tree
Dojo Tree          In this section, you will learn about the tree and how to create a tree in dojo.  Try Online: Tree Tree :  The tree is a GUI that helps to lists
Java gui program for drawing rectangle and circle
Java gui program for drawing rectangle and circle   how to write java gui program for drawing rectangle and circle? there shoud be circle and rectangle button, check box for bold and italic, and radio button red,green and blue
Java: Example - Drawing a Face - v5
Java: Example - Drawing a Face - v5 Main - Setting the instance variables 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...); // Put drawing in window. window.pack(); // Adjust to fit
tree view - Java Beginners
tree view   I m using swing for the treeview in my application and also the database(Hsqldb). I want to connect the tree view with the database fields. If u want more clarification ,let me know. Thanks
Tree traversal
Tree traversal       Tree traversal Tree traversal have following method : .children... through the ancestors of these elements in the DOM tree and construct a new jQuery
arithmetic expression tree
arithmetic expression tree  how to create the java code randomly for arithmetic expression tree
Creating Dynamic Tree
Creating Dynamic Tree   Creating Dynamic Tree: I have to build a tree structure with the following data lets say that with this data childId... is that i need to have a way to construct a tree. Please let me know how can i
Java: Example - Drawing a Face
Java: Example - Drawing a Face This simple application creates... the paintComponent method to do the drawing. 1 2 3 4 5 6 7...()); // set its layout PacLady drawing = new PacLady
binary search tree
binary search tree  Construct a binary search tree by inserting the following sequence of characters into an empty tree. N O N L I N E A R D A T A Visit the tree using all three traversal algorithms and list the output sequence

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.