Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

math456

Can someone help me with this java problem?

  • one year ago
  • one year ago

  • This Question is Closed
  1. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    • one year ago
  2. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    I have my program MyString. public class MyString { public static String reverse(String s) { String reverse = ""; for(int i=s.length() - 1; i >=0; i--) { reverse = reverse + s.charAt(i); } return reverse; } public static boolean isPalindrome(String s) { String a = reverse(s); if(a.equals(s)) { return true; } return false; } public static boolean match(String s1, String s2) { return s1.equals(s2); } public static int mismatchCount(String s1, String s2) { int counter = 0; for(int i=0; i < s1.length(); i++) { if(s1.charAt(i)!=s2.charAt(i)) { counter++; } } return counter; } public static boolean similar(String s1, String s2) { int mismatch = mismatchCount(s1,s2); return mismatch<=1; } public static void printPositions(String key, String target) { for(int j = 0; j <= target.length() - key.length(); j++) { if(target.substring(j,j+key.length()).equals(key)) { System.out.println(j); } } } }

    • one year ago
  3. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    Does this JUnit Test look okay? import junit.framework.TestCase; public class TestMyString extends TestCase { public void testReverse() { assertEquals(MyString.reverse("cat"),"tac"); } public void testisPalindrome() { assertEquals("isPalindrome","eye","eye"); //returns true if eye is the same when reversed assertEquals("isPalindrome","horse","horse"); //returns false when they aren't the same } public void testMatch() { assertEquals("match","dog","dog"); } public void testMismatchCount() { assertEquals("mismatchcount","bow","bow"); } public void testSimilar() { assertEquals("similar","boo","boo"); } }

    • one year ago
  4. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    @cwrw238 @ganeshie8 @TuringTest

    • one year ago
  5. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    @dpaInc @Hero

    • one year ago
  6. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    @KonradZuse @eSpex

    • one year ago
  7. snark
    Best Response
    You've already chosen the best response.
    Medals 1

    seems to run and work ok - just add the usual public static void main(String[] args){ } - you can run all your tests within it.

    • one year ago
  8. math456
    Best Response
    You've already chosen the best response.
    Medals 0

    i just have to test those five methods in the "Test Output" window, so i don't need to run it!

    • one year ago
  9. KonradZuse
    Best Response
    You've already chosen the best response.
    Medals 0

    I've never used JUnit.....

    • one year ago
  10. KonradZuse
    Best Response
    You've already chosen the best response.
    Medals 0

    Not sure what exactly it does, maybe I have, I know it's included in my IDE Netbeans....

    • one year ago
  11. Thats-me
    Best Response
    You've already chosen the best response.
    Medals 0

    I came up with the same answer as Snark

    • one year ago
  12. bookworm00981
    Best Response
    You've already chosen the best response.
    Medals 0

    snarks right

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.