Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Link to question: http://codecheck.it/files?repo=fall2017&problem=q2 So I found the answer to this question, but I'm not sure how the tester file for this would look. So

Link to question: http://codecheck.it/files?repo=fall2017&problem=q2

So I found the answer to this question, but I'm not sure how the tester file for this would look. So here is the Strings.uniqueLetters(String str) method which is the answer:

public class Strings

{

public static String uniqueLetters(String str)

{

String ret = "";

for(int i = 0; i < str.length(); ++i) {

boolean found = false;

for(int j = 0; j < str.length(); ++j) {

if(i != j && str.charAt(i) == str.charAt(j)) {

found = true;

}

}

if(!found) {

ret += str.charAt(i);

}

}

return ret;

}

}

But I'm having trouble writing the testing file. How would I test this in eclipse? I am converting to Java from C++ and I am quite confused. This is what I have so far:

public class Tester

{

public static void main(String[] args)

{

String str = "bananas";

Strings.uniqueLetters(str);

System.out.println(Strings.toString(str));

System.out.println("Expected: bs");

}

}

Please tell me how the testing program should look like. Thank you!

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

Distinguish between facultative reinsurance and treaty reinsurance.

Answered: 1 week ago

Question

Discuss whether we can control stereotyping.

Answered: 1 week ago