forked from angiejones/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeAreaCalculator.java
More file actions
33 lines (25 loc) · 860 Bytes
/
Copy pathHomeAreaCalculator.java
File metadata and controls
33 lines (25 loc) · 860 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
package chapter6;
/*
* Write a class that creates instances of the Rectangle class to find the
* total area of two rooms in a house.
*/
public class HomeAreaCalculator {
public static void main(String args[]){
/*******************
* RECTANGLE 1
********************/
//Create instance of Rectangle class
Rectangle room1 = new Rectangle();
room1.setWidth(25);
room1.setLength(50);
double areaOfRoom1 = room1.calculateArea();
/*******************
* RECTANGLE 2
********************/
//Create instance of Rectangle class
Rectangle room2 = new Rectangle(30, 75);
double areaOfRoom2 = room2.calculateArea();
double totalArea = areaOfRoom1 + areaOfRoom2;
System.out.println("Area of both rooms: " + totalArea);
}
}