zopiac

Pythagorean v.1

Oct 8th, 2010
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import turtles.*;
  2. public class Pythagorean extends TurtleProgram {
  3.     private static final long serialVersionUID = 1L;
  4.  
  5.     public void run() {
  6.         this.setSize(800, 600);
  7.         Turtle marisa = new Turtle (400, 300);
  8.         int lega = readInt("leg a");
  9.         int legb = readInt("leg b");
  10.         double angle = (45 * (lega / legb));
  11.         int variable =(lega * lega) + (legb * legb);
  12.         double hypot = (double) Math.sqrt(variable);
  13.         marisa.forward(lega);
  14.         marisa.left(90);
  15.         marisa.forward(legb);
  16.         marisa.left(180);
  17.         marisa.right(angle);
  18.         marisa.forward(hypot);
  19.         marisa.hide();
  20.         System.out.println("lega: " + lega + "\nlegb: " + legb + "\nhypot: " + hypot + "\nvariable: " + variable + "\nangle: " + angle);
  21.     }
  22. }
Add Comment
Please, Sign In to add comment