Question: JAVA CODING The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem,

JAVA CODING

The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. Make sure the DebugBox class compiles without error, the DebugBox class methods work without error, the DebugFour3 class compiles without error and The DebugFour3 program accepts user input and displays the correct output.

An example of the program is shown below:

Enter width of box >> 10 Enter length of box >> 15 Enter height of box >> 5 The dimensions of the first box are Width: 1 Length: 1 Height: 1 The volume of the first box is 1.0 The dimensions of the second box are Width: 10 Length: 15 Height: 5 The volume of the second box is 750.0

FIST CODE:

public class DebugBox

{

private int width;

private int length;

private int height;

public DebugBox()

{

length = 1;

width = 1;

height = 1;

}

public DebugBox(int width, int length, int height)

{

this.width = width;

this.length = width;

this.height = width;

}

public void showData()

{

System.out.println("Width: " + width + " Length: " +

length + " Height: " + height);

}

public getVolume()

{

double vol = length * width * height;

return vol;

}

}

SECOND CODE:

import java.util.Scanner;

public class DebugFour3

{

public static void main(String args[])

{

Scanner input = new Scanner(System.in);

int w, l, h;

System.out.print("Enter width of box >> ");

w = input.nextInteger();

System.out.print("Enter width of box >> ");

l = input.nextDouble();

System.out.print("Enter width of box >> ");

h = input.nextInt();

DebugBox box1 = new FixDebugBox();

DebugBox box1 = new FixDebugBox(w, l, h);

System.out.println("The dimensions of the first box are");

box1.showData();

System.out.print(" The volume of the first box is ");

showVolume(box1);

System.out.println("The dimensions of the second box are");

box2.showData();

System.out.print(" The volume of the second box is ");

box2.showVolume();

}

public static void showVolume(DebugBox aBox)

{

double vol = aBox.getVolume();

System.out.println(vol);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!