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 java.util.Scanner; 11 import shapes.SSquare; 12 13 public class SurfaceAreaOfCube { 14 public static void main(String[] args) { 15 double edgeLength = edgeLength(); 16 double surfaceArea = surfaceArea(edgeLength); 17 System.out.println("surface area = " + surfaceArea); 18 } 19 20 private static double edgeLength() { 21 System.out.print("Please enter the edge length of the cube: "); 22 Scanner scanner = new Scanner(System.in); 23 double edgeLength = scanner.nextDouble(); 24 return edgeLength; 25 } 26 27 private static double surfaceArea(double edgeLength) { 28 SSquare face = new SSquare(edgeLength); 29 int nrOfFaces = 6; 30 double surfaceArea = face.area() * nrOfFaces; 31 return surfaceArea; 32 } 33 } 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57