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



Home Answers Viewqa Java-Beginners drawing triange using stars
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


goodie
drawing triange using stars
1 Answer(s)      6 years and 11 months ago
Posted in : Java Beginners


How do i Write a program to draw the boundaries of a plot of land with the structure shown in the diagram, for any set of input values for the dimensions. Use ?*? to represent the sides


Advertisement
View Answers

April 2, 2008 at 8:48 PM


Triangle.java

import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;

public class Triangle{
public static void main(String args[]){
Polygon tri = new Polygon();
tri.addPoint(0,25);
tri.addPoint(25,0);
tri.addPoint(50,25);
Rectangle rect = tri.getBounds();
BufferedImage img = new BufferedImage(rect.width,rect.height,BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
g.setColor(Color.white);
g.fill(rect);
g.setColor(Color.black);
g.fill(tri);
int x,y;
for (y = 0;y < img.getHeight();y++) {
for (x = 0; x< img.getWidth();x++) {
if (img.getRGB(x,y) == 0xffffffff)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println("");
}
}
}


Related Tutorials/Questions & Answers:
drawing triange using stars - Java Beginners
drawing triange using stars  How do i Write a program to draw the boundaries of a plot of land with the structure shown in the diagram, for any set of input values for the dimensions. Use ?*? to represent the sides   
stars question
stars question  program to get this output
Advertisements
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
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 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
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.
Line Drawing - Swing AWT
Line Drawing  How to Draw Line using Java Swings in Graph chart... using java Swing import javax.swing.*; import java.awt.Color; import...) { System.out.println("Line draw example using java Swing"); JFrame frame = new
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
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
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 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
How can i display the distance of a line drawing randomly?
How can i display the distance of a line drawing randomly?  How can i display the distance of a line drawing randomly
importing excel file and drawing multiple graphs from one excel file
importing excel file and drawing multiple graphs from one excel file  thanks a lot sir for replying with code for importing excel file... time from one excel file using different columns..and instead of passing column
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
Java - Drawing Shapes Example using color in java
Java - Drawing Shapes Example using color in java       Introduction In this program we will show you how to draw the different types of colorful shapes. This example show
drawing rectangle in java/Creating a draw rectangle filled with black color function in Java for a grid
drawing rectangle in java/Creating a draw rectangle filled with black color function in Java for a grid  drawing rectangle in java/Creating a draw rectangle (filled with black color) function in Java for a grid
Simple Line Canvas Example
Simple Line Canvas Example       This is a simple example of drawing lines using canvas class in J2ME. In this example we are creating three different lines at different
to write an SQL query using insert statement
to write an SQL query using insert statement  I need to write an sql query for the below using InSERT command.pls help. Insert 5-star ratings.... Rating ( rID, mID, stars, ratingDate ) English: The reviewer rID gave the movie
Drawing with Color in Java
Drawing with Color in Java     ... these with the appropriate color. Following are some methods are using in the given program... class is used to drawing different-different type of shapes). This method draws
Print Screen Using Java Swing
Print Screen Using Java Swing   ... that describes how to send drawing to the printer. To start drawing the Graphics..." file for print the display value. In this step using print() method
Arcs Drawing In Java
Arcs Drawing In Java      .... In this program we are using the BasicStroke() method. You can learn about this method in the previous program. Here, this program is using the "Arcs2D.Double"
Drawing with Gradient Color in Java
Drawing with Gradient Color in Java       In this section, you will learn how to draw the colorful...; this program. Program draws a rectangle using Graphics2D and GradientPaint(). 
Flex Circle drawing example
Flex circle drawing example       Example below draw circles on the panel... for drawing a circle is defined inside the Sprite class of flash.display
Java - Drawing Shapes Example in java
Java - Drawing Shapes Example in java       Introduction Applet is a program to run on the browser and it is embedded on the web page. This program is not system level program
 

 

 

DMCA.com