Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Module 08: Final - Debugging Assignment In this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program

Module 08: Final - Debugging Assignment

In this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program below. Fix the code, and paste it in this document, along with a list of the problems you fixed.

This example allows the user to create an ArrayList that contains a list of states. There should be only one entry per state in the list. There is another method to verify the uniqueness of the list.

import java.util.ArrayList;

import stringCollections.StoreStrings;

public class TestStoreStrings {

public static void main(String[] args) {

ArrayList<> states = new ArrayList();

states.add("Virginia");

states.add("New York")

states.add("Michigan");

states.add("Indiana");

states.add("Missouri");

states.add("Indiana");

states.sort(null);

for(String state:states) {

System.out.println(state)

}

if (StoreStrings.duplicateString(states)) {

System.out.println("Error! Contains more than one entry of the same state in the list. Must have only one entry for the state in the list");

} else {

System.out.println(StoreStrings.count(states));

}

}

}

package stringCollections;

import java.util.ArrayList;

public class StoreStrings {

public static int count(ArrayList words)

{

int lSize = 0;

for(String i : words)

{

lSize++;

}

return lSize;

}

public static boolean duplicateString(ArrayList words) {

boolean isDuplicateString = False;

ArrayList<> items = new ArrayList();

for(String word : words)

{

if (items.contains(word)) {

isDuplicateString = True;

}else {

items.add(word);

}

}

return isDuplicateString;

}

}

CORRECTED CODE:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago

Question

=+7 How has the COVID-19 pandemic impacted the operations of IHRM?

Answered: 1 week ago