We have a programming assignment for my Java Programming class and I can't figure out to fix my output. Here's the code:
class Box {
double width;
double height;
double depth;
double w2, h2, d2;
double v2;
Box() {
}
Box(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
void getVolume() {
System.out.println("Volume is : " + width * height * depth);
}
void Match(double a, double b, double c) {
w2 = a;
h2 = b;
d2 = c;
}
void getNumber() {
System.out.println("# of Matches is : " + width * height * depth / v2);
}
}
public class fep2 extends Box {
double weight;
fep2() {
}
fep2(double w, double h, double d, double m) {
super(w, h, d);
weight = m;
}
fep2(double a, double b, double c) {
super(a, b, c);
double v2 = a * b * c;
}
public static void main(String args[]) {
fep2 mb1 = new fep2(10, 10, 10, 10);
fep2 mb2 = new fep2(2, 2, 2);
mb1.getVolume();
mb2.getNumber();
System.out.println("width of MatchBox 1 is " + mb1.width);
System.out.println("height of MatchBox 1 is " + mb1.height);
System.out.println("depth of MatchBox 1 is " + mb1.depth);
System.out.println("weight of MatchBox 1 is " + mb1.weight);
}
}
And here's my output:
Volume is : 1000.0
# of Matches is : Infinity
width of MatchBox 1 is 10.0
height of MatchBox 1 is 10.0
depth of MatchBox 1 is 10.0
weight of MatchBox 1 is 10.0
The number of matches in the box shouldn't be infinity. By my math it should've came out ot 125. Can anyone please help?