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