-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangleMain.java
More file actions
34 lines (26 loc) · 837 Bytes
/
Copy pathRectangleMain.java
File metadata and controls
34 lines (26 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package testReview;
public class RectangleMain {
public static void main(String[] args)
{
Rectangle [] recArray = new Rectangle [5];
for (int i = 0; i < recArray.length; i++)
{
Rectangle temp = new Rectangle((int)((Math.random()*10) + 1), (int)((Math.random()*10) + 1));
recArray[i] = temp;
System.out.println("Length is: " + temp.getLength());
System.out.println("Width is: " + temp.getWidth());
}
int maxIndex = 0;
double maxArea = recArray[0].getArea();
for (int i = 1; i < recArray.length; i++)
{
if (recArray[i].getArea() > maxArea)
{
maxArea = recArray[i].getArea();
maxIndex = i;
}
}
System.out.println("Length is: " + recArray[maxIndex].getLength());
System.out.println("Width is: " + recArray[maxIndex].getWidth());
}
}