Writing a method to compute such an array from a string

Assignment Help JAVA Programming
Reference no: EM13865176

Write a program called Assg3.java to solve the following problem.

Write a java program in one file to determine if a string is an anagram of another string where a typical run of your program is to be as follows.

% java Assg3 restful fluster
"restful" is an anagram of "fluster"

The two items provided on the command line may include spaces and punctuation marks. All non-letters are to be ignored as if they were absent. Convert text to lower case (use a method in the String class) before attempting to determine whether one argument is an anagram of the other. To ensure that the spaces are preserved in these two command-line arguments, use double quotation marks as follows, when running your program.

% java Assg3 "Forty five" "Over Fifty"
"Forty five" is an anagram of "Over Fifty"

If the first argument is not an anagram of the second, say 'is not' instead of 'is' in the output text, but otherwise leave it in the same form.

If you need a hint or help in inventing how this program should be organized, speak with the instructor or with a T.A. and we'll gladly suggest how you can proceed to solve this problem. Read the hint below first.

Hint: Two items are anagrams (of each other) when they contain the same number of 'a's and the same number of 'b's, etcetera, and the same number of 'z's. So a table indicating how many of each letter is in an item could be computed from that item, as follows.

 

"Forty five"

 

a

0

 

b

0

 

c

0

 

d

0

 

e

1

 

f

2

 

g

0

 

h

0

 

i

1

 

j

0

 

k

0

 

l

0

 

m

0

 

n

0

 

o

1

 

p

0

 

q

0

 

r

1

 

s

0

 

t

1

 

u

0

 

v

1

 

w

0

 

x

0

 

y

1

 

z

0

Now two items are anagrams exactly when their respective tables are equal. A simple way to represent such a table is as an array A of 26 integers. Then A[0] is the number of 'a's, A[1] is the number of 'b's and so forth. Given a variable ch of type char, A[ch-'a'] is A[0] if the value of ch is 'a', or is A[1] if the value of ch is 'b', and so forth. And the condition 'a'<=ch && ch<='z' is true exactly when the value of ch is a lower case letter, as indicated in class.

Writing a method to compute such an array from a String and return it, and a second method to take two such arrays and return a boolean indicating whether they are equal is sufficient to write a simple solution the remainder of which is the main method.

Reference no: EM13865176

Questions Cloud

Should our evaluation of one lifetime of hard work : No security leaks had been found In accepting  Piraeus resignation President Obama praised Piraeus leadership during the Iraq and Afghanistan wars and said By any measure through his lifetime of service David Petra us has made our country safer and s..
Explain how to declare and manipulate data in arrays : Please respond to all of the following prompts: Explain how to declare and manipulate data in arrays. Explain the meaning of "array index out of bounds".
Speculators had better information about future exchange ra : If speculators had better information about future exchange rates, would their actions be more or less stabilizing than at present?
Do you think enlightened self-interest is a contradiction : Do you think enlightened self-interest is a contradiction in terms or is it a valid basis for all action? Evaluate whether our laissez-faire  free-market economic system does (or should) operate under this philosophy
Writing a method to compute such an array from a string : Write a java program in one file to determine if a string is an anagram of another string where a typical run of your program is to be as follows. % java Assg3 restful fluster"restful" is an anagram of "fluster"
Write program that takes theelevator-nxtthrough calibration : Write the program that takes theElevator-NXTthrough a calibration and test sequence, as shown in thisvideo. Raise the car as far as it goes to the top (the top floor).
Irac method - grunden-martin vs fairmount : Solved the given cases using IRAC format- Case 1- Meran v. MacDonald, 2006 U.S. Dist. LEXIS 79069 (U.S. Dist. Ct. S.D. Cal.) and Case 2- Grunden-Martin v. Fairmount
Describes the challenges related to defining terrorism : Challenges related to defining terrorism
Explain the meaning of this phrase as you see it : Macintyre in his account of Aristotelian virtue, states that integrity is the one trait of character that encompasses all the others. How does integrity relate to as Macintyre said, the wholeness of a human life?David Starr Jordan (1851 1931) an edu..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd