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 surgave area will be printed to the standard output stream. 5 * - A face o fthe cube will be modeled as a simple square. 6 */ 7 8 package mathematics; 9 10 11 import shapes.SSquare; 12 13 import java.util.Scanner; 14 15 public class SurfaceAreaOfCube { 16 17 public static void main(String[] args) { 18 double edgeLength = edgeLength(); 19 double surfaceArea = surfaceArea(edgeLength); 20 System.out.println("surface area = " + surfaceArea); 21 } 22 23 24 private static double edgeLength() { 25 System.out.print("Please enter the edge length of the cube: "); 26 Scanner scanner = new Scanner(System.in); 27 double edgeLength = scanner.nextDouble(); 28 return edgeLength; 29 } 30 31 private static double surfaceArea(double edgeLength) { 32 SSquare face = new SSquare(edgeLength); 33 int nrOfFaces = 6; 34 double surfaceArea = face.area() * nrOfFaces; 35 return surfaceArea; 36 } 37 } 38 39