Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Esercizio1{
- public static void main (String [] urgs) {
- Punto a,b; /* 4 variabili del tipo definito dalla classe Punto */
- /* creiamo 2 nuovi oggetti della classe Punto */
- a = new Punto(1,1);
- b = new Punto(2,2);
- System.out.println(diagonale(a,b));}
- public static double diagonale(Punto a, Punto b){
- 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))));
- return y;
- }
- }
- class Punto {
- double x;
- double y;
- public Punto(double x, double y){
- this.x=x;
- this.y=y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement