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
2 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]2 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
When TCP/IP translates a network layer address into a data link layer address, it sends a special ____________ to all computers
Llana [10]

Answer:

Broadcast message

Explanation:

The network models like OSI and TCP/IP suites have standard layers and protocols that governs the communication of end devices in a network.

The TCP/IP suite model has four layers which are application, transport, internet and network access layers. The network access does the work of both the data-link and physical layer of the OSI model.

When the packet is encapsulated in a data-link header and trailer, and needs to be sent to another unknown host, a broadcast message is sent to all the computers in the network to retrieve the remote host address for a unicast transmission to take place.

3 0
3 years ago
Read 2 more answers
A computer can manipulate symbols as if it understands the symbols and is reasoning with them, but in fact it is just following
Law Incorporation [45]

Answer:

The symbols may or may not have meaning, but the machine does not need to know how the symbols are interpreted in order to manipulate the symbols in the right way.

Explanation:

The computer can change the symbols in the case when the computer understand but in actual following the cut-paste rules without having any understanding this is because the symbols might be have meaning or not but if we talk about the machine so actually they dont know how the symbols are interpreted and how it can be used so that it can be change in the accurate way

5 0
2 years ago
One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
salantis [7]

Answer:

import java.util.Scanner;

public class Miles {

public static void main(String[] args) {

   //initialization

       double Number_Miles;

       //print the message

       System.out.print("Enter the number of miles: ");

       Scanner scn1 = new Scanner(System.in);

       

       Number_Miles = scn1.nextDouble();  //read the input from user

       //calculate the laps

       double yourValue = Number_Miles/0.25;

       //display the output on the screen

       System.out.printf("%.2f", yourValue);

     

}

}  

Explanation:

First import the library Scanner than create the class and define the main function. In the main function, declare the variables.

print the message on the screen and then store the value enter by the user into the variable.

Scanner is a class that is used for reading the output. So, we make the object of the class Scanner and then object call the function nextDouble() which reads the input and store in the variable.

After that, calculate the number of laps by dividing the number of miles with the given one lap running track value (0.25 miles).

Number\,of\,laps = \frac{Number\,of\,miles}{0.25}

the output is stored in the variable.

After that, print the value on the screen with 2 digits after the decimal point.

we can use "%.2f" in the printing function in java.

like System.out.printf("%.2f", output);

5 0
2 years ago
Read 2 more answers
Decimal numbers are based on __________.
MaRussiya [10]
They are based on 10 digits.

I’m not sure.
8 0
3 years ago
Read 2 more answers
1. Think about the various ways in which you have seen hackers portrayed in popular media over the past few years. Are they hero
Eva8 [605]
They are definitely not heroic characters, so you can rule that out. Definitely dangerous criminals. If you need me to help further I can. Is that a question or an essay?
3 0
3 years ago
Other questions:
  • ___ is the branch of computer science that explores techniques for incorporating aspects of intelligence into computer systems.
    5·1 answer
  • Which quality of service (QoS) mechanism provided by the network does real-time transport protocol (RTP) rely on to guarantee a
    13·1 answer
  • Which of the following, (1) money deposited in a bank account, (2) student recording her answer to a question in an online test,
    9·1 answer
  • What is the target audience of an ad?
    11·1 answer
  • List two types of energy sources
    10·2 answers
  • Suppose that we want to multiply 500 matrices and we use the optimal parenthesization computed by the MATRIX-CHAIN-ORDER functio
    13·2 answers
  • Which part of a computer is responsible for executing the software programs?
    10·1 answer
  • Setting up a desktop computer for anAutoCADspecialist who needs a minimum of 125 GBram which operating system would be the best
    5·1 answer
  • Write a function solution that, given an array A consisting of N integers, returns the number of fragements of A whose sum equal
    9·1 answer
  • Avi does not want to save his internet browsing details on his computer. What should he do?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!