Question

In: Computer Science

The files provided in the code editor to the right contain syntax and/or logic errors. In...

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.

DebugBox.java

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, height)
{
width = width;
length = length;
height = height;
}
public void showData()
{
System.out.println("Width: + width + " Length: " +
length + " Height: "+ height);
}
public double getVolume()
{
double vol = length + wdth + height;
return vol;
}
}

DebugFour3.java

// This class uses a DebugBox class to instantiate two Box objects
public class DebugFour3
{
public static void main(String args[])
{
int width = 12,
length = 10,
height = 8;
DebugBox box1 = new DebugBox();
debugBox box2 = new DebugBox(width, length, height);
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 ");
showVolume(box2);
}
public static void showVolume(DebugBox aBox)
{
double vol = aBox.getVolume();
System.out.println(volume);
}
}

Solutions

Expert Solution

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 = length;
        this.height = height;
    }

    public void showData() {
        System.out.println("Width:" + width + " Length:" + length + " Height: " + height);
    }

    public double getVolume() {
        double vol = length * width * height;
        return vol;
    }
}
public class DebugFour3 {
    public static void main(String args[]) {
        int width = 12,
                length = 10,
                height = 8;
        DebugBox box1 = new DebugBox();
        DebugBox box2 = new DebugBox(width, length, height);
        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 ");
        showVolume(box2);
    }

    public static void showVolume(DebugBox aBox) {
        double vol = aBox.getVolume();
        System.out.println(vol);
    }
}


Related Solutions

The files provided in the code editor to the right contain syntax and/or logic errors. In...
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. Please Fix code and make Copy/Paste avaliable // Application allows user to enter a series of words // and displays them in reverse order import java.util.*; public class DebugEight4 {    public static void main(String[] args)    {       Scanner input = new Scanner(System.in);       int...
The following code segment which uses pointers may contain logic and syntax errors. Find and correct...
The following code segment which uses pointers may contain logic and syntax errors. Find and correct them. a) Returns the sum of all the elements in summands int sum(int* values) { int sum = 0; for (int i = 0; i < sizeof(values); i++) sum += *(values + i); return sum; } b) Overwrites an input string src with "61C is awesome!" if there's room. Does nothing if there is not. Assume that length correctly represents the length of src....
Each of the following files in the Chapter15 folder of your downloadable student files has syntax and/or logic errors.
Each of the following files in the Chapter15 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded with Fix. For example, DebugFifteen1.java will become FixDebugFifteen1.java. a. DebugFifteen1.java b. DebugFifteen2.java c. DebugFifteen3.java d. DebugFifteen4.java    
identify the syntax errors in the following code:             public class Hello {                    &
identify the syntax errors in the following code:             public class Hello {                         private static int main(String [] args) {                                     string Msg=”Hello, Wrld!;                                     Sytem.out.println(msg+ “Ken")
To earn full credit, program must be free of syntax, run-time, and logic errors; include program...
To earn full credit, program must be free of syntax, run-time, and logic errors; include program comments; use reasonable readable variable names and prompts. To include variables in the input prompt, you must use concatenation character (+). For example: assume you already asked for input of employee's first name and last name (they are stored into variables FirstName and LastName, then use this prompt to ask for employee's weekly hours which includes the employee's full name in the input statement....
Please use C++. You will be provided with two files. The first file (accounts.txt) will contain...
Please use C++. You will be provided with two files. The first file (accounts.txt) will contain account numbers (10 digits) along with the account type (L:Loan and S:Savings) and their current balance. The second file (transactions.txt) will contain transactions on the accounts. It will specifically include the account number, an indication if it is a withdrawal/deposit and an amount. Both files will be pipe delimited (|) and their format will be the following: accounts.txt : File with bank account info...
***The code is provided below*** When trying to compile the code below, I'm receiving three errors....
***The code is provided below*** When trying to compile the code below, I'm receiving three errors. Can I get some assistance on correcting the issues? I removed the code because I thought I corrected my problem. I used #define to get rid of the CRT errors, and included an int at main(). The code compiles but still does not run properly. When entering the insertion prompt for the call details, after entering the phone number, the program just continuously runs,...
There are two errors in this code. Identify the errors and give the correct code that...
There are two errors in this code. Identify the errors and give the correct code that will make the program to display the following output: Rectangle: height 2.0 width 4.0 Area of the Rectangle is 8.0 ----- public interface Shape { public double getArea(); } class Rectangle implements Shape { double height; double width; public Rectangle(double height, double width) { this.height=height; this.width=width; } public double getArea() { return height*width; } public String toString() { return "Rectangle: height "+height+" width "+width;...
Quality assurance department of software house reveals that 6.5% of programming code contain logical errors. Quality...
Quality assurance department of software house reveals that 6.5% of programming code contain logical errors. Quality check software is developed to analyze code and in a test, identifies the error in 90% of the code with errors and 5% of those without. If code is marked by the program as possibly having a logical error, what is the probability that the code DOES have an error?
The number of errors in each of 300 files has a Poisson distribution with 1.4 errors...
The number of errors in each of 300 files has a Poisson distribution with 1.4 errors per file on average. Assume the errors in different files are independent. Use the Central Limit Theorem to approximate the probability that the total number of errors is at least 400. (Use a calculator.)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT