Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. class Esercizio1{
  2.   public static void main (String [] urgs) {
  3.        Punto a,b;  /* 4 variabili del tipo definito dalla classe Punto */
  4.    
  5.     /* creiamo 2 nuovi oggetti della classe Punto */
  6.     a = new Punto(1,1);
  7.     b = new Punto(2,2);
  8.  
  9.    
  10.   System.out.println(diagonale(a,b));}
  11.    
  12.    public static double diagonale(Punto a, Punto b){
  13.      double y= +Math.sqrt(((Math.max(a.x,b.x)-Math.min(a.x,b.x))*(Math.max(a.x,b.x)-Math.min(a.x,b.x)))-((Math.max(a.y,b.y)-Math.min(a.y,b.y))*(Math.max(a.y,b.y)-Math.min(a.y,b.y))));
  14.      return y;
  15.   }
  16.  
  17. }
  18. class Punto {  
  19.  
  20.   double x;  
  21.   double y;
  22.  
  23.   public Punto(double x, double y){
  24.     this.x=x;          
  25.     this.y=y;    
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement