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   
16       public static void main(String[] args){
17           double edgeLength = edgeLength();
18           double surfaceArea = surfaceArea(edgeLength);
19           System.out.println("Surface are = " + surfaceArea);
20       }
21   
22       private static double edgeLength() {
23           System.out.print("Please enter the edge length of the cube: ");
24           Scanner scanner = new Scanner(System.in);
25           double edgeLength = scanner.nextDouble();
26           return  edgeLength;
27       }
28   
29       private static double surfaceArea(double edgeLength) {
30           SSquare face = new SSquare(edgeLength);
31           int nrOfFaces = 6;
32           double surfaceArea = face.area() * nrOfFaces;
33           return surfaceArea;
34       }
35   
36   }
37