/home/kchan2/NetBeansProjects/CS1/src/mathematics/SurfaceAreaofCube.java |
1
2
3
4
5
6
7
8 package mathematics;
9
10 import java.util.Scanner;
11 import shapes.SSquare;
12
13
14
15 @author
16
17 public class SurfaceAreaofCube {
18
19
20 @param args
21
22 public static void main(String[] args) {
23 double edgeLength = edgeLength();
24 double surfaceArea = surfaceArea(edgeLength);
25 System.out.println("surface area = " + surfaceArea);
26 }
27
28 private static double edgeLength() {
29 System.out.print("Please enter the edge length of the cube: ");
30 Scanner scanner = new Scanner(System.in);
31 double edgeLength = scanner.nextDouble();
32 return edgeLength;
33 }
34
35 private static double surfaceArea(double edgeLength) {
36 SSquare face = new SSquare(edgeLength);
37 int nrOfFaces = 6;
38 double surfaceArea = face.area() * nrOfFaces;
39 return surfaceArea;
40 }
41
42 }
43