1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
monitta
3 years ago
7

An anagram is a word or a phrase made by transposing the letters of another word or phrase; for example, "parliament" is an anag

ram of "partial men," and "software" is an anagram of "swear oft." Write a program that figures out whether one string is an anagram of another string. The program should ignore white space and punctuation.
Computers and Technology
1 answer:
Sliva [168]3 years ago
4 0

Answer:

Anagram

Explanation:

public class Anagram {

   public static boolean areAnagrams(String string1,

                                     String string2) {

       String workingCopy1 = removeJunk(string1);

       String workingCopy2 = removeJunk(string2);

    workingCopy1 = workingCopy1.toLowerCase();

    workingCopy2 = workingCopy2.toLowerCase();

    workingCopy1 = sort(workingCopy1);

    workingCopy2 = sort(workingCopy2);

       return workingCopy1.equals(workingCopy2);

   }

   protected static String removeJunk(String string) {

       int i, len = string.length();

       StringBuilder dest = new StringBuilder(len);

   char c;

    for (i = (len - 1); i >= 0; i--) {

        c = string.charAt(i);

        if (Character.isLetter(c)) {

         dest.append(c);

        }

    }

       return dest.toString();

   }

   protected static String sort(String string) {

    char[] charArray = string.toCharArray();

    java.util.Arrays.sort(charArray);

       return new String(charArray);

   }

   public static void main(String[] args) {

       String string1 = "Cosmo and Laine:";

       String string2 = "Maid, clean soon!";

       System.out.println();

       System.out.println("Testing whether the following "

                        + "strings are anagrams:");

       System.out.println("    String 1: " + string1);

       System.out.println("    String 2: " + string2);

       System.out.println();

       if (areAnagrams(string1, string2)) {

           System.out.println("They ARE anagrams!");

       } else {

           System.out.println("They are NOT anagrams!");

       }

       System.out.println();

   }

}

You might be interested in
Which is better? iPhone 11 Pro Max or Samsung Galaxy Note 20 Ultra 5G and why?
Allisa [31]

Answer:

Samsung note 20 or iPhone but i think Samsung

Explanation:

8 0
3 years ago
Read 2 more answers
Is the app scener safe? its a chrome webstore app on computer.​
Sophie [7]

Answer:

Maybe

Explanation:

If you are unsure if a website is safe look for signs. If its asking you to allow advertisement then no. I suggest you download a VPN before going to the website just to be safe

5 0
3 years ago
If you type =5*3 into a cell, what do you expect the answer will be?
Ilya [14]

Answer:

I think 15

what do you mean by cell

Explanation:

3 0
3 years ago
Read 2 more answers
Use a _____ to safeguard computer systems from voltage fluctuations.
liq [111]

Answer.

1.Surge protection board

2.Uninterrupted Power Supply (UPS)


Explanation

A surge protection board is designed to protect equipment against a power surge or over voltage in power supply.A UPS provides back up power in occasions of power outage.In most events of power cut,UPS units only allow a person to save the work and perform a controlled shutting down of a computer.

4 0
3 years ago
According to Darwin’s theory of evolution, differences between species may be a result of which of the following?
ArbitrLikvidat [17]

Explanation:

Your answer is C natural selection.

8 0
3 years ago
Read 2 more answers
Other questions:
  • String word = “Awesome”;
    9·2 answers
  • As the performance of PCs steadily improves, computers that in the past were classified as midrange computers are now marketed a
    9·1 answer
  • (Palindrome integer) Write the methods with the following headers // Return the reversal of an integer, i.e., reverse(456) retur
    9·1 answer
  • A computer can sort x objects in t seconds, as modeled by the function below:
    5·1 answer
  • The hardware to keep the output data when finished is a
    9·1 answer
  • What is boolean rules​
    12·1 answer
  • What effect would excluding quotation marks from a search phrase have?
    12·1 answer
  • Write a function that will sum all of the numbers in a list, ignoring the non-numbers. The function should takes one parameter:
    8·1 answer
  • If someone you don’t know asks where you go to school, what should you do
    12·1 answer
  • Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form a/b, in which a and b a
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!