SurfaceAreaOfCube.java
1    /* 
2     * Program that features two functions to compute the surface area of a cube. 
3     * -The edge lenght 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    import java.util.Scanner;
10   import shapes.SSquare;
11   
12   public class SurfaceAreaOfCube {
13       public static void main(String[] args) {
14           double edgeLength = edgeLength();
15           double surfaceArea = surfaceArea(edgeLength);
16           System.out.println("surface area = " + surfaceArea);
17       }
18   
19       private static double edgeLength() {
20           System.out.print("Please enter the edge length of the cube: ");
21           Scanner scanner = new Scanner (System.in);
22           double edgeLength = scanner.nextDouble();
23           return edgeLength;
24       }
25   
26       private static double surfaceArea(double edgeLength) {
27           SSquare face = new SSquare(edgeLength);
28           int nrOfFaces = 6;
29           double surfaceArea = face.area() * nrOfFaces;
30           return surfaceArea;
31       }
32   }
33