forked from angiejones/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeAreaCalculatorRedo.java
More file actions
38 lines (23 loc) · 1001 Bytes
/
Copy pathHomeAreaCalculatorRedo.java
File metadata and controls
38 lines (23 loc) · 1001 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
35
36
37
38
package chapter6;
import java.util.Scanner;
public class HomeAreaCalculatorRedo {
private Scanner scanner = new Scanner(System.in);
public static void main(String args[]){
HomeAreaCalculatorRedo calculator = new HomeAreaCalculatorRedo();
Rectangle kitchen = calculator.getRoom();
Rectangle bathroom = calculator.getRoom();
double area = calculator.calculateTotalArea(kitchen, bathroom);
System.out.println("The total area is: " + area);
calculator.scanner.close();
}
public Rectangle getRoom(){
System.out.println("Enter the length of your room:");
double length = scanner.nextDouble();
System.out.println("Enter the width of your room:");
double width = scanner.nextDouble();
return new Rectangle(length, width);
}
public double calculateTotalArea(Rectangle rectangle1, Rectangle rectangle2){
return rectangle1.calculateArea() + rectangle2.calculateArea();
}
}