package shapes; import java.util.Scanner; public class ShippingContainer { public static void main(String[]args){ Scanner c = new Scanner(System.in); System.out.print("please enter the width, length and height: "); double width = c.nextDouble(); double length = c.nextDouble(); double height = c.nextDouble(); System.out.println("This Container is "+width +" wide, " +length+" deep and " + height +" high"); SRectangle face = new SRectangle(length, width); double Kh = face.diagonal(); SRectangle key = new SRectangle(Kh ,height); double distance = key.diagonal(); System.out.println("The longest distance of the container is: " + distance); } }
Demo please enter the width, length and height: 32 45 67 This Container is 32.0 wide, 45.0 deep and 67.0 high The longest distance of the container is: 86.82165628459296 Process finished with exit code 0