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
This is your code. >>> A = ['dog''red'] >>> B = [' cat', 'blue']>>>C = ['fish', 'green'] You can impl
natima [27]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The given Python code is:

>>> A = ['dog''red']

>>> B = [' cat', 'blue']

>>>C = ['fish', 'green']

We can implement an array of this data by using the dictionary in Python.

Dictionary in python:

A dictionary in python stores (key-value) pairs. For example, we can implement the -given arrays A, B, and C in the dictionary as given below:

d={'dog : red', 'cat : blue', 'fish : green'}

print(d['dog']) # Get an entry from a dictionary; prints "red"

print('cat' in d)    # Check if a dictionary has a given key; prints "True"

d['fish'] = 'black'    # Set an entry in a dictionary

print(d['fish'])      # Prints "black"

# print(d['elephant'])  # KeyError: 'elephant' not a key of d

print(d.get('elephant', 'N/A'))  # Get an element with a default; prints "N/A"

print(d.get('fish', 'N/A'))   # Get an element with a default; prints "black"

del d['dog']        # Remove an element from a dictionary

print(d.get('dog', 'N/A')) # "dog" is no longer a key; prints "N/A"

3 0
2 years ago
Read 2 more answers
Why is Brainly always deleting either my answers or my questions? I am putting nothing inappropriate in them. Can someone answer
Artist 52 [7]

Answer:

hey i do not know

Explanation:

3 0
3 years ago
Read 2 more answers
________is one of the most popular payment gateways founded in in December 1998​
iren2701 [21]

paypel is the most popular

6 0
3 years ago
When an instance of a class, or object, is specified as a parameter to a method, a reference to the said object is passed to the
OLEGan [10]
Or pointer

VERY similar.
5 0
3 years ago
Levi's an experienced marketing strategist for a software company that sells a learning platform to public schools. He developed
koban [17]

Answer:

B. He segments data using his company’s CRM dashboards, giving his organization access to data that powers their decision-making.

E. He encourages learning from failure, which is necessary for testing the possibilities and for learning what does not work.

Explanation:

He seems to have realized that learning from mistake is important, and that can be done through the research of the company's past. Also, he has also learnt to analyze the data as well, as he is able to constantly evolve company.s marketing strategies to fit to school's training needs. And this is impossible without analysis and research. It also looks like that he is a good learner, and loves exploring new things. And he must be using analytic software like Tableau OR Power BI, and he might be using Machine learning as well, and definitely the latest. And he is definitely a good manager.

And since its management level, B is definitely correct as it is reliable, and other options are not reliable.

6 0
3 years ago
Other questions:
  • What is the unique impact him professionals have on coded data?
    11·1 answer
  • You are given n sorted sequences each one containing n keys. You may assume n is a power of two. We want to merge them into one
    15·1 answer
  • An individual is first with the network before they are authorized to access resources on the network A. countermeasure B. vulne
    11·1 answer
  • Given the following narrative for Bambino’s Pizzeria, list the actors that should be used in the use-case diagram.
    6·1 answer
  • The chip that controls the radio frequency waves within a device
    9·1 answer
  • How are computers used in education and entertainment? List them.​
    10·1 answer
  • Cuantos MB son 8,192 kb?​
    13·1 answer
  • Write a technical term for following statements
    15·1 answer
  • Which spreadsheet feature could the scholarship committee use to locate applicants who meet the criteria?
    10·1 answer
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!