Question: import java.util.*; /**************************************************************** This class contains several methods with multiple logical errors. Although, it should compile with no errors. Create a new class called dubuggingTest

 import java.util.*; /**************************************************************** This class contains several methods with multiple logical

import java.util.*; /**************************************************************** This class contains several methods with multiple logical errors. Although, it should compile with no errors.

Create a new class called dubuggingTest that contains a single main() to test all methods. Create multiple tests for each method. Use the provided main() below as a start.

****************************************************************/ public class Debugging{ /** quantity on hand for sale */ private int inventory; /** constants used for convertion to farenheit temperatures */ private final double RATIO = 9 / 5; private final int BASE = 32; /****************************************************************** Copy this method to a new class called "debuggingTest" and add more tests for each method. ******************************************************************/ public static void main(String args[]){ Debugging bug1 = new Debugging(); if(bug1.calcAverage("10 20 30 -100") != 20.0){ System.out.println("ERROR: Average of 10, 20 and 30 should be 20.0"); } } /****************************************************************** Default constructor should set inventory to -1 ******************************************************************/ public Debugging(){ inventory = 0; } /****************************************************************** Alternative constructor should set inventory @param inventory amount to be assigned to the instance field ******************************************************************/ public Debugging(int inventory){ inventory = inventory; } /****************************************************************** Set inventory @param inventory amount to be assigned to the instance field ******************************************************************/ public void setInventory(int amount){ amount = inventory; } /****************************************************************** Get inventory @return the current inventory ******************************************************************/ public int getInventory(){ return inventory; } /****************************************************************** Calculate the 'base' raised to the 'exp' power For example, power(2, 4) should return 16 @param base the number to be raised @param exp the exponent @return a new number that represents base raised to the exp power. ******************************************************************/ public int power(int base, int exp){ int result = 0; for(int i=1; i= 61 + over && speed 0) total = total + val; count++; }while(val > 0); return total / count; } /**************************************************************** Return a new String that has all occurence of character c removed. For exmample removeChar("Help!!!!", '!') returns "Help" @param str the initial String @param c the character to be removed from str @return the modified String @return the computed average of all positive numbers ****************************************************************/ public String removeChar(String str, char c){ String result = ""; int index = 0; while(index

}

Objectives After completing this lab you should be able to: find errors in someone else's code Step 1: Create a New BlueJ Project Step 2: Download Debugging.java We created a class with several methods that have some devious bugs! Create a new class called Debugging and delete all of the starter code. Cut and paste the provided code from (Debugging.java) into the newly created class. It should compile with no errors. Step 3: Create a new class called DebuggingTest Copy the main ) provided in Debugging.java to get you started. Read what each method is supposed to do and then write test cases for each (except for getInventory). Write one test case for each of the constructors and setInventory(). Write TWO test cases for the remaining five methods. However, caughtSpeeding () should have four tests. Therefore, your test harness should have fifteen tests

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!