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 output 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 9 import shapes.SSquare; 10 11 import java.util.Scanner; 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 surfaceArea(double edgeLength) { 21 SSquare face = new SSquare(edgeLength); 22 int nrOfFaces = 6; 23 double surfaceArea = face.area()*nrOfFaces; 24 return surfaceArea; 25 } 26 27 private static double edgelength() { 28 System.out.print("Please enter the edge length of the cube: "); 29 Scanner scanner = new Scanner (System.in); 30 double edgeLength = scanner.nextDouble(); 31 return edgeLength; 32 } 33 } 34