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 import java.util.Scanner; 10 import shapes.SSquare; 11 public class SurfaceAreaOfCube { 12 public static void main(String[] args) { 13 double edgeLength = edgeLength(); 14 double surfaceArea = surfaceArea(edgeLength); 15 System.out.println("surface area = " + surfaceArea); 16 } 17 private static double edgeLength() { 18 System.out.print("Please enter the edge length of the cube: "); 19 Scanner scanner = new Scanner(System.in); 20 double edgeLength = scanner.nextDouble(); 21 return edgeLength; 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