Let x represent the edge length of the square end. Then the area of the end of the package is x², and the length of the package is 126 -4x. The overall volume is ...
V = x²×(126 -4x)
V = -4x³ +126x²
The volume will be a maximum where the derivative of volume with respect to x is zero.
V' = -12x² +252x
V' = -12x(x -21)
This will be zero for x = 0 and for x = 21
The maximum volume of the package is
V = (21 in)²(126 in -4×21 in)
V = 18,522 in³