drawing triange using stars

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

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
ModuleNotFoundError: No module named 'stars'
ModuleNotFoundError: No module named 'stars'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'stars' How to remove the ModuleNotFoundError: No module named 'stars'
ModuleNotFoundError: No module named 'moving-stars'
ModuleNotFoundError: No module named 'moving-stars'  Hi, My Python... 'moving-stars' How to remove the ModuleNotFoundError: No module named 'moving-stars' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'STARS-CMS'
ModuleNotFoundError: No module named 'STARS-CMS'  Hi, My Python... 'STARS-CMS' How to remove the ModuleNotFoundError: No module named 'STARS... have to install padas library. You can install STARS-CMS python with following
ModuleNotFoundError: No module named 'stars-rating'
ModuleNotFoundError: No module named 'stars-rating'  Hi, My Python... 'stars-rating' How to remove the ModuleNotFoundError: No module named 'stars-rating' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stars-zs'
ModuleNotFoundError: No module named 'stars-zs'  Hi, My Python... 'stars-zs' How to remove the ModuleNotFoundError: No module named 'stars-zs... to install padas library. You can install stars-zs python with following
ModuleNotFoundError: No module named 'geo-stars'
ModuleNotFoundError: No module named 'geo-stars'  Hi, My Python... 'geo-stars' How to remove the ModuleNotFoundError: No module named 'geo-stars' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'drawing'
ModuleNotFoundError: No module named 'drawing'  Hi, My Python... 'drawing' How to remove the ModuleNotFoundError: No module named 'drawing... to install padas library. You can install drawing python with following command
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
ModuleNotFoundError: No module named 'gh-stars-export'
ModuleNotFoundError: No module named 'gh-stars-export'  Hi, My... named 'gh-stars-export' How to remove the ModuleNotFoundError: No module named 'gh-stars-export' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'oh-my-stars'
ModuleNotFoundError: No module named 'oh-my-stars'  Hi, My Python... 'oh-my-stars' How to remove the ModuleNotFoundError: No module named 'oh-my-stars' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'oh-my-stars'
ModuleNotFoundError: No module named 'oh-my-stars'  Hi, My Python... 'oh-my-stars' How to remove the ModuleNotFoundError: No module named 'oh-my-stars' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'thank-you-stars'
ModuleNotFoundError: No module named 'thank-you-stars'  Hi, My... named 'thank-you-stars' How to remove the ModuleNotFoundError: No module named 'thank-you-stars' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-rating-stars'
ModuleNotFoundError: No module named 'django-rating-stars'  Hi, My... named 'django-rating-stars' How to remove the ModuleNotFoundError: No module named 'django-rating-stars' error? Thanks   Hi
ModuleNotFoundError: No module named 'gh-stars-export'
ModuleNotFoundError: No module named 'gh-stars-export'  Hi, My... named 'gh-stars-export' How to remove the ModuleNotFoundError: No module named 'gh-stars-export' error? Thanks   Hi, In your python
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.
Printing stars
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
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
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
ModuleNotFoundError: No module named 'jupyter-drawing-pad'
ModuleNotFoundError: No module named 'jupyter-drawing-pad'  Hi, My... named 'jupyter-drawing-pad' How to remove the ModuleNotFoundError: No module named 'jupyter-drawing-pad' error? Thanks   Hi
ModuleNotFoundError: No module named 'jupyter-drawing-pad'
ModuleNotFoundError: No module named 'jupyter-drawing-pad'  Hi, My... named 'jupyter-drawing-pad' How to remove the ModuleNotFoundError: No module named 'jupyter-drawing-pad' error? Thanks   Hi
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
Print Screen Using Java Swing
Print Screen Using Java Swing   ... that describes how to send drawing to the printer. To start drawing the Graphics.... In this step using print() method. This method sets of pages.ADS_TO_REPLACE_3
using array
using array  transpose a matrix
using array
using array  transpose a matrix
using prompt
using prompt  how to use prompt
using array
using array  column wise total of a matrix
using function
using function   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
using array
using array  Circular left shift array element by one position
using array
using array  Circular left shift array element by one position
using array
using array  read 10 digit number and display (star
using array
using array  display 10 digit number using array and print pyramid. 1 1 1 1 1 1 1 1 1 1 1 1

Ads