/* * A program that calculates the longest object that can be shoved into a container */ package shapes; import java.util.Scanner; public class ShippingContainer { public static void main(String[] args){ double Width,Length,Height; Width = Length = Height = 0; // Ask the user for input. Scanner scanner = new Scanner(System.in); System.out.print("Enter 3 dimensions of the container: "); int i = 0; while(i < 3){ if(i == 0){ Width = scanner.nextDouble(); } if(i == 1){ Length = scanner.nextDouble(); } if(i == 2){ Height = scanner.nextDouble(); } i++; } // Compute the diagonal rectangle double Face = Math.sqrt(Math.pow(Width, 2) + Math.pow(Length, 2)); // Computer the DIAGONAL of the diagonal rectangle double Key = Math.sqrt(Math.pow(Height, 2) + Math.pow(Face, 2)); System.out.println("The longest object you can shove in is " + Key); } }