/* ------------------------------------------------------------------- http://www.phys.lsu.edu/faculty/tohline/PHYS2411/q3.dir/casting.java ------------------------------------------------------------------- This java applet draws an uncolored equilateral triangle into the window of a web browser that reads in an arbitrary "sideLength". ------------------------------------------------------------------- */ import java.applet.*; import java.awt.*; import java.lang.*; public class casting extends Applet { int x1 = 10; int y1 = 10; int half, width; float sqrt_3Over2 = 0.866025F; public void init () { Integer length = new Integer(getParameter( "sideLength" )); width = length.intValue(); Float xHalf = new Float(sqrt_3Over2 * length.floatValue()); half = xHalf.intValue(); } public void paint (Graphics gc){ gc.drawLine(x1, y1, x1 + width, y1 ); gc.drawLine(x1 + width, y1, x1 + width/2, y1+half); gc.drawLine(x1, y1, x1 + width/2, y1+half); } }