SurfaceAreaOfCube.java
1    /* 
2     * Program that features two functions to compute the surface area of a cube. 
3     *  - The edge length will be read from the standard input stream. 
4     *  - The surface area will be printed to the standard output stream. 
5     *  - A face of the cube will be modeled as a simple square 
6     */
7    
8    
9    package mathematics;
10   
11   import java.util.Scanner;
12   import shapes.SSquare;
13   
14   public class SurfaceAreaOfCube {
15   
16       public static void main(String[] args) {
17           double edgeLength = edgeLength();
18           double surfaceArea = surfaceArea(edgeLength);
19           System.out.println("Surface Area = " + surfaceArea + " units");
20   
21       }
22   
23       private static double edgeLength() {
24           System.out.println("Please enter the edge length of the cube: ");
25           Scanner scanner = new Scanner(System.in);
26           double edgeLength = scanner.nextDouble();
27           return edgeLength;
28   
29       }
30   
31       private static double surfaceArea(double edgeLength) {
32           SSquare face = new SSquare(edgeLength);
33           int nrOfFaces = 6;
34           double surfaceArea = face.area() * nrOfFaces;
35           return surfaceArea;
36   
37       }
38   
39   }
40