2016-10-10 15:10:32 +00:00
|
|
|
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;
|
2016-10-10 15:21:33 +00:00
|
|
|
Scanner in = new Scanner(System.in);
|
2016-10-10 15:10:32 +00:00
|
|
|
|
2016-10-10 15:11:25 +00:00
|
|
|
System.out.println("Inserisci la x, la y, la larghezza e l'altezza: ");
|
|
|
|
ret = new Rectangle(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
|
2016-10-10 15:10:32 +00:00
|
|
|
|
2016-10-10 15:11:25 +00:00
|
|
|
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;
|
2016-10-10 15:10:32 +00:00
|
|
|
}
|
2016-10-10 15:11:25 +00:00
|
|
|
System.out.println("Inserisci la x, la y, la larghezza e l'altezza: ");
|
|
|
|
ret = new Rectangle(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
|
|
|
|
}
|
2016-10-10 15:10:32 +00:00
|
|
|
|
2016-10-10 15:11:25 +00:00
|
|
|
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");
|
2016-10-10 15:10:32 +00:00
|
|
|
}
|
|
|
|
}
|