Question: Programming Project: Super Anagrams Your job for this assignment is to solve a slight variant of the traditional anagram problem called superanagram. Here you are

Programming Project: Super Anagrams Your job for this assignment is to solve a slight variant of the traditional anagram problem called superanagram. Here you are to write a two class application that reads in two words or phrases from the keyboard, and then outputs true if the first phrase is an anagram of some of the letters in the second phrase, false if it is not. Here are some examples:

* mo / moo (true) * mo / mOO (true - capitalization doesn't matter) * moo / mo (false - first phrase is NOT an anagram of some (or all) of letters of second) * rip / ziPPer (true) * abc / aabc (true) * aabc / abcde (false - too few a's in the second string) * flipper / rip (false) * Clint Eastwood / Old west Action! (true - the two can have exactly the same letters) * a stitch in time saves nine / is this meant as an incentive? (true) * narcissism / one man crisis (false- can you see why?)

Example of a program run: Enter a phrase: > Clint Eastwood Enter another phrase: >Old west Action! true

I have done some work about this assignment, but I just realize that there are some mistakes in my code,and I have no idea where they are. Can you tell me how to fix my code? 1 import java.util.Scanner;

public class SuperAnTester{

public static void main(String[] args){

Scanner scan = new Scanner(System.in); System.out.println("Enter a phrase: "); String a=scan.nextLine(); System.out.println("Enter another phrase: "); String b=scan.nextLine(); SuperAnagram twopharses = new SuperAnagram(a,b);

System.out.println(twopharses.isSuperAnagram());

}

}

2 class SuperAnagram{ private String first; private String second; private char firstArray[]; private char secondArray[]; public SuperAnagram(String a, String b){ first = a; second = b; } public void cleanSymbols(){ first.replaceAll(" ",""); first.replaceAll("[\\pP]",""); second.replaceAll(" ",""); second.replaceAll("[\\pP]",""); } public void firstchar(){ first.toLowerCase(); firstArray = first.toCharArray(); } public void secondchar(){ second.toLowerCase(); secondArray = second.toCharArray(); } public boolean isSuperAnagram(){ firstchar(); secondchar(); boolean isSuperAnagram=false; if(firstArray.length>secondArray.length){ isSuperAnagram=false; return isSuperAnagram; } else{ for (int k=0; k

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!