ShippingContainer.java
1    /* 
2     * Compute the distance from one corner of a rectangular shipping container on the floor (bottom) to its far corner 
3     *      on the ceiling (top). Prompt the user for container width, length, and height and work with these values. 
4     */
5    package shapes;
6    
7    import java.util.Scanner;
8    
9    public class ShippingContainer {
10       public static void main(String[] args) {
11           //Need a scanner for user input
12           Scanner scanner = new Scanner(System.in);
13   
14           //prompt for user input
15           System.out.print("Enter a container width: ");
16           double containerWidth = (double)scanner.nextInt();
17   
18           System.out.print("Enter a container height: ");
19           double containerHeight = (double)scanner.nextInt();
20   
21           System.out.print("Enter a container length: ");
22           double containerLength = (double)scanner.nextInt();
23   
24           //Determine diagonal for bottom/top container faces (this will be the curtain width)
25           SRectangle face = new SRectangle(containerWidth, containerLength);
26           double curtainWidth = face.diagonal();
27           double curtainHeight = containerHeight;
28   
29           //create the curtain rectangle (key) with these constructions
30           SRectangle key = new SRectangle(curtainWidth, curtainHeight);
31           double distance = key.diagonal(); //distance between the far 2 corners of the container (what we are looking for)
32   
33           //Display result to output stream
34           System.out.println("The longest object you can shove in this shipping container diagonally, from bottom corner to opposite top corner: " + distance);
35       }
36   }
37