This commit is contained in:
Orange_Dugongo 2016-10-10 17:10:32 +02:00
parent cb00299fcb
commit dcb3dfd369
9 changed files with 60 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

31
src/Rettangolo.java Normal file
View File

@ -0,0 +1,31 @@
import java.io.*;
import java.awt.*;
public class Rettangolo{
public static void main(String [] args){
Rectangle box = new Rectangle(2,3, 20,30);
Rectangle box2 = new Rectangle(3,4, 10, 40);
double p1, p2, a1, a2;
if(box.getY() < box2.getY())
System.out.println("Il box 1 è più in alto");
else
System.out.println("Il box 2 è più in alto");
p1=2*(box.getHeight() + box.getWidth());
p2=2*(box2.getHeight() + box2.getWidth());
if(p1>p2)
System.out.println("Il box 1 ha perimetro maggiore");
else
System.out.println("Il box 2 ha perimetro maggiore");
a1=box.getHeight() * box.getWidth();
a2=box2.getHeight() * box2.getWidth();
if(a1>a2)
System.out.println("Il box 1 ha area maggiore");
else
System.out.println("Il box 2 ha area maggiore");
}
}

View File

@ -0,0 +1,29 @@
import java.awt.Rectangle;
import java.util.Scanner;
public class RettangoloDaTastiera{
public static void main(String[] arg){
Rectangle ret, retMax=null;
int i=0, imax=0;
Scanner in = new Scanner(System.in);
System.out.println("Inserisci la x, la y, la larghezza e l'altezza: ");
ret = new Rectangle(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
while(ret.getX()!=0 || ret.getY()!=0 || ret.getWidth()!=0 || ret.getHeight()!=0){
i++;
if(retMax==null || ret.getWidth()*ret.getHeight()>retMax.getWidth()*retMax.getHeight()){
retMax=ret;
imax=i;
}
System.out.println("Inserisci la x, la y, la larghezza e l'altezza: ");
ret = new Rectangle(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
}
if(retMax==null)
System.out.println("IMPOSSIBILE ESEGURE L'OPERAZIONE.\nSono stati inseriti zero rettangoli");
else
System.out.println("Il "+imax+"° ha l'area massima");
}
}