hi
having a little problem with pythagorem theorem the problem is is that I've wrote the formula to find the length of the hypotenuse line but when I draw this to the screen the line is longer tha my right triangle help would be appreciated
I do have an image but having trouble uploading it but will try
having a little problem with pythagorem theorem the problem is is that I've wrote the formula to find the length of the hypotenuse line but when I draw this to the screen the line is longer tha my right triangle help would be appreciated
package trigSystem; import java.awt.*; import javax.swing.*; public class TrigGUI1 extends JFrame { /** * */ private static final long serialVersionUID = 1L; public TrigGUI1() { // TODO Auto-generated constructor stub super(); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setSize( 500, 500 ); setVisible( true ); } public void rightTriangle( Graphics g ) { g.drawLine( 250, 250, 400, 250 ); g.drawLine( 400, 250, 400, 100 ); g.setColor( Color.RED ); g.drawLine( 250, 250, 250 + ( int )pythagoremTheorem(), 250 - ( int )pythagoremTheorem() ); } public double pythagoremTheorem() { double adj = 150; double opp = 150; double hyp = opp * opp + adj * adj; double calc = Math.sqrt( hyp ); //System.out.println( "Pythagorem length: " + calc ); return calc; } public void paint( Graphics g ) { super.paint( g ); rightTriangle( g ); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub new TrigGUI1(); } }
I do have an image but having trouble uploading it but will try