ShippingContainer.java
1    /* 
2     * This program calculates the longest distance from corner to opposite corner of a 3d rectangle 
3     */
4    
5    package shapes;
6    
7    import java.util.Scanner;
8    
9    public class ShippingContainer {
10   
11       public static void main(String[] args){
12   
13           // Declaration of Variables //
14           int width;
15           int length;
16           int height;
17   
18           double distance;
19           double keyLength;
20   
21           // Creates scanner
22           Scanner scanner = new Scanner(System.in);
23   
24           // Prompts user for width, length and height while recording values
25           System.out.println("Enter Width: ");
26           width = scanner.nextInt();
27           System.out.println("Enter Length: ");
28           length = scanner.nextInt();
29           System.out.println("Enter Height: ");
30           height = scanner.nextInt();
31   
32           // Creates bottom face of shipping container
33           SRectangle bottomFace = new SRectangle(length, width);
34   
35           // Obtains diagonal of bottom face to get key length
36           keyLength = bottomFace.diagonal();
37   
38           // Creates key based on key length and height
39           SRectangle key = new SRectangle(keyLength, height);
40   
41           // Obtains distance by getting diagonal of key
42           distance = key.diagonal();
43   
44           // Display result
45           System.out.println("The longest distance possible is: " + distance + " Units");
46       }
47   
48   }
49