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