I've been working on this for a while and can't seem to get my head around it. I'm trying to calculate the volume and surface area from the length, height, and width (without putting the volume or surface area in the data fields) using the accessor method. I'm not sure why my code is coming up with these errors (see below) and would appreciate some educating as I'm really trying to learn how to code! Thank You :)
Error: cannot find symbol symbol: variable volume location: class Box
Error: cannot find symbol symbol: variable surfaceArea location: class Box
public class Box {
//data field declarations
public int height; //height
public int width; //width
public int length; //length
/**sets the value of the data field height to input parameter value*/
public void setheight(int H){
height = H;
}
//end method
/**sets the value of the data field width to input parameter value*/
public void setwidth(int W){
width = W;
}
//end method
/**sets the value of the data field length to input parameter value*/
public void setlength(int L){
length = L;
}
//end method
/**A constructor which takes 3 parameters**/
public Box(int H, int L, int W){
H = height;
L = length;
W = width;
}
/**Constructor which creates a box**/
public Box(){
}
/**Constructor which creates a cube**/
public Box(int side){
side = height;
side = length;
side = width;
}
/**returns the value of the data field SurfaceArea **/
int getsurfaceArea(){
return (2*height) + (2*width) + (2*length);
}
//end method
/**returns the value of the data field volume */
int getvolume(){
return height*width*length;;
}
//end method
/**displays formatted Box information to the console window */
public String toString(){
return "Height is: " + height + ", Length is: " + length + ", Width is: " + width + ", Volume is: " + volume + ", Surface Area: " + surfaceArea;
}
//end method
}