Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M91525891
  • Price:- $50

Guranteed 36 Hours Delivery, In Price:- $50

Have any Question?


Related Questions in Java

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As