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