1 /* 2 * Program to take the dimensions of a shipping container in integer form and return the longest possible 3 * object that can fit diagonally in the container. 4 */ 5 6 package shapes; 7 8 import java.util.Scanner; 9 10 public class ShippingContainer { 11 public static void main(String [] args){ 12 //create the variables for the measurements of the shipping container and bind them to the 13 //scanner inputs 14 double width = width(); 15 double length = length(); 16 double height = height(); 17 double distance = keydiagonal(width, length, height); 18 //now return the longest object that can fit into the container 19 System.out.println("The longest object that can fit into the shipping container with the dimensions" + 20 "you provided is: " + distance + "units"); 21 22 } 23 //ask the user for the with, length, and height, and return it to the variables 24 25 private static int width(){ 26 System.out.print("Please enter the width, in units, of the shipping container: "); 27 Scanner scannerW = new Scanner(System.in); 28 int width = scannerW.nextInt(); 29 return width; 30 } 31 32 private static int length(){ 33 System.out.print("Please enter the length, in units, of the shipping container: "); 34 Scanner scannerL = new Scanner(System.in); 35 int length = scannerL.nextInt(); 36 return length; 37 } 38 39 private static int height() { 40 System.out.print("Please enter the height, in units, of the shipping container: "); 41 Scanner scannerH = new Scanner(System.in); 42 int height = scannerH.nextInt(); 43 return height; 44 } 45 46 //create keydiagonal() to return the diagonal of the key, using height, length, width, and 47 //conceptual shapes. 48 private static double keydiagonal(double width, double length, double height){ 49 //use the width and length to create the floor of the shipping container, then find it's 50 //diagonal using SRectangle 51 SRectangle face = new SRectangle(width, length); 52 double keylength = face.diagonal(); 53 //use the diagonal of "face" and the height to create "key" 54 SRectangle key = new SRectangle(height, keylength); 55 //find the diagonal of the "key" and return it for the longest object that can fit into 56 //the shipping container 57 double distance = key.diagonal(); 58 return distance; 59 60 } 61 } 62