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
The main events of the civil war and reconstruction
rosijanka [135]
While many still debate the ultimate causes of the Civil War<span>, Pulitzer Prize-winning author James McPherson writes that, "The </span>Civil War started<span> because of uncompromising differences between the free and slave states over the power of the national government to prohibit slavery in the territories that had not yet become </span>
3 0
4 years ago
Assume the existence of a Building class with a constructor that accepts two parameters:_________ a reference to an Address obje
Maksim231197 [3]

Answer:

class Building { int toatalUnit; Building(Building add, int x) { } } public class ApartmentBuilding extends Building { int toatalUnit; ApartmentBuilding(ApartmentBuilding add, int a, int b) { super(add, b); this.toatalUnit = b; } }

Explanation:

Assume the existence of a Building class with a constructor that accepts two parameters:_________ a reference to an Address object representing the building's address, and an integer for the square footage of the building. Assume a subclass ApartmentBuilding has been defined with a single integer instance variable, totalUnits. Write a constructor for ApartmentBuilding that accepts three parameters: an Address and an integer to be passed up to the Building constructor, and an integer used to initialize the totalUnits instance variable.

class Building { int toatalUnit; Building(Building add, int x) { } } public class ApartmentBuilding extends Building { int toatalUnit; ApartmentBuilding(ApartmentBuilding add, int a, int b) { super(add, b); this.toatalUnit = b; } }

5 0
3 years ago
Petra notices that there are a number of issues with a new fiber optic connection whose status appears to be going up and down c
DanielleElmas [232]

Fiber Internet is the wired choice of our present times. It has replaced traditional copper-based facilities.

<h3></h3>

How fiber optics are connected?

  • Fiber to the curb (FTTC) means your fiber connection goes to the nearest pole or utility box—not an actual concrete curb. After that, coaxial cables will send signals from the “curb” to your home. This means your connection is made up of part fiber-optic cables, part copper wires.
  • Twisted pair cabling simply refers to a wiring whereby two conductors that are gotten from a single circuit will be twisted together so that their electromagnetic compatibility can be enhanced.
  • This type of network cable is commonly used to connect office computers to the local network and it is used for Ethernet networks. A circuit is formed from the pair of wires which can be used in the transmission of data.
  • Fiber optic internet is a data connection carried by a cable filled with thin glass or plastic fibers. Data travels through them as beams of light pulsed in a pattern. Fiber optic internet speeds are about 20 times faster than regular cable at 1 Gbps.

To learn more about fiber refer to:

brainly.com/question/21808066

#SPJ4

5 0
1 year ago
Your client expresses that they want their new website to have a responsivedesign with consistent coding. They are concerned wit
tresset_1 [31]

D

Explanation:

Because that's the one that works good together

5 0
3 years ago
What is the purpose of the ISOWEEKNUM function
stellarik [79]

Answer:

Explanation:

The ISOWEEKNUM Function in Excel is a Date & Time Function. This cheat sheet covers 100s of functions that are critical to know as an Excel analyst used for finding out the ISO week number of the year for the given date value (e.g., week number 37 of 52 weeks in a year). The function was introduced in MS Excel 2013.

7 0
3 years ago
Read 2 more answers
Other questions:
  • An employee who interacts with customers regarding the nature of their car problems, rather than actually working on the vehicle
    6·1 answer
  • Given the following characteristics for a magnetic disk pack with 10 platters yielding 18 recordable surfaces (not using the top
    14·1 answer
  • During executing of the ______ PR task, units regain control of IP and transfer physical custody to the reintegration team.
    6·1 answer
  • Which type of microphone uses two metal plates?
    7·1 answer
  • In order to view the permissions assigned to each type of user for all the files located in a directory, which of the following
    12·1 answer
  • Another name for the office button menu is the toolbar. true or false.
    7·2 answers
  • According to the passage, what are the goals of the<br> program? Check all that apply.
    11·1 answer
  • This is more a question for Brainly,
    5·2 answers
  • What are the common internal components to most electronic devices?
    10·1 answer
  • which one of the following portfolios cannot lie on the efficient frontier as described by markowitz? portfolioexpected returnst
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!