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    package mathematics;
8    //IMPORTS
9    import java.util.Scanner;
10   import shapes.SSquare;
11   
12   public class SurfaceAreaOfCube {
13       public static void main(String[] args) {
14           //SET VALUES TO VARIABLES
15           double edgeLength = edgeLength();
16           double surfaceArea = surfaceArea(edgeLength);
17           //OUTPUT SURFACE AREA
18           System.out.println("surface area = " + surfaceArea);
19       }
20       //ASK FOR AND RECEIVE 2 VARIABLES (edgeLength + nrOfFaces)
21       private static double edgeLength() {
22           System.out.print("Please enter the edge length of the cube: ");
23           Scanner scanner = new Scanner(System.in);
24           double edgeLength = scanner.nextDouble(); //RECEIVES SCANNER INPUT
25           return edgeLength;
26       }
27       private static double surfaceArea(double edgeLength) {
28           SSquare face = new SSquare(edgeLength);
29           int nrOfFaces = 6;
30           double surfaceArea = (face.area() * nrOfFaces); //MULTIPLIES AREA OF FACE AND # OF FACES
31           return surfaceArea;
32       }
33   }