I have to extend a class from squareDemo in this assignment. All i need to do is add depth to the compute surface area arithmetic. It wont allow me to print in the extended class. I also cant grab height, width from the parent class which I "thought" was the purpose of inheritance. Please help with code and explain how my logic is flawed. I'm a new programmer so please go easy on me heh...
package square; /** * * @author Michael * Chapter 9 exercise 2 */ public class SquareDemo { public static void main(String[] args) { int height = 6; int width = 6; int surfaceAreaSQ = height * width; System.out.println("The surface area of the square is: " + surfaceAreaSQ); } public class CubeDemo extends SquareDemo { int height = 6; int width = 6; int depth = 6; int surfaceAreaCU = height * width * depth; System.out.println("The surface area of the cube is: " + surfaceAreaCU); } }