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    package mathematics;
9    
10   import shapes.SSquare;
11   
12   import java.util.Scanner;
13   
14   public class SurfaceAreaOfCube {
15       public static void main(String[] args) {
16           double edgeLength = edgeLength();
17           double surfaceArea = surfaceArea(edgeLength);
18           System.out.println("Surface Area = " +surfaceArea);
19       }
20   
21       private static double edgeLength(){
22           System.out.println("Please enter the edge length of the cube: ");
23           Scanner scanner = new Scanner(System.in);
24           double edgeLength = scanner.nextDouble();
25           return edgeLength;
26       }
27   
28       private static double surfaceArea(double edgeLength) {
29           SSquare face = new SSquare(edgeLength);
30           int nrOfFaces = 6;
31           double sufaceArea = face.area() * nrOfFaces;
32           return sufaceArea;
33       }
34   }
35