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



Home Answers Viewqa Java-Beginners drawing a christmas tree
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


goodie
drawing a christmas tree
1 Answer(s)      6 years and 7 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


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
Christmas countdown Java
Christmas countdown Java  Assignment: Write a program that reads in a date and calculates the number of days until Christmas for that year . You can... date: 12122014 Date is: December 12, 2014 Days until Christmas: 13 And here
Christmas countdown Java
Christmas countdown Java  Assignment: Write a program that reads in a date and calculates the number of days until Christmas for that year . You can... date: 12122014 Date is: December 12, 2014 Days until Christmas: 13 And here
Tree
Tree  print("code sample");1) Write Java code to create the following tree using new Tree state- ments: 1
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
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
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
tree view
tree view  display a tree view in flex?nodes will be in the form
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
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
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
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
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
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
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
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 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
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
Advertisements
 

 

 

DMCA.com