SurfaceAreaOfCube.java
1    /* 
2    Program that features two functions to compute the SA of a cube 
3    -Edge length is read from the Standard input stream 
4    -SA is printed to the standard output stream 
5    -The face of the cube is 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           double edgeLength = edgeLength();
19           double surfaceArea = surfaceArea(edgeLength);
20           System.out.println("surface area = " + surfaceArea);
21       }
22   
23       private static double surfaceArea(double edgeLength) {
24           SSquare face = new SSquare(edgeLength);
25           int nrOfFaces = 6;
26           double surfaceArea = face.area() * nrOfFaces;
27           return surfaceArea;
28       }
29   
30       private static double edgeLength() {
31           System.out.print("Please enter the edge length of the cube: ");
32           Scanner scanguy = new Scanner(System.in);
33           double edgeLength = scanguy.nextDouble();
34           return edgeLength;
35       }
36   }
37