1 /* 2 * Pogram 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 15 public static void main(String[] args) { 16 double edgelength = edgelength(); 17 double surfacearea = surfacearea(edgelength); 18 System.out.println("surface area = " + surfacearea); 19 } 20 21 private static double surfacearea(double edgelength) { 22 SSquare face = new SSquare(edgelength); 23 int nrOfFaces = 6; 24 double surfacearea = face.area() * nrOfFaces; 25 return surfacearea; 26 } 27 28 private static double edgelength() { 29 System.out.println("Please enter the edge length of the cube: "); 30 Scanner scanner = new Scanner(System.in); 31 double edgelength = scanner.nextDouble(); 32 return edgelength; 33 } 34 35 36 } 37 38 39 40 41