SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 3 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Jan 2018 My Price 8.00

phrases in English are anagrams if their letters

Two words or phrases in English are anagrams if their letters (and only their letters), rearranged, are the same. We assume that upper and lower case are indistinguishable, and punctuation and spaces don't count. Some examples and non-examples of regular anagrams:

 

* The eyes / they see (yes)

* moo / mo (no)

* Clint Eastwood / Old west Action! (yes)

* Dormitory / Dirty Room (yes)

 

Your job for this assignment is to solve a slight variant of the traditional anagram problem calledsuperanagram. Here you are to write a two class application that reads in two words or phrases from the keyboard, and then outputs true if the first phrase is an anagram ofsomeof the letters in the second phrase, false if it is not. Here are some examples:

 

* mo / moo (true)

* mo / mOO (true - capitalization doesn't matter)

* moo / mo (false - first phrase is NOT an anagram of some (or all) of letters of second)

* rip / ziPPer (true)

* abc / aabc (true)

* aabc / abcde (false - too few a's in the second string)

* flipper / rip (false)

* Clint Eastwood / Old west Action! (true - the two can have exactly the same letters)

* a stitch in time saves nine / is this meant as an incentive? (true)

* narcissism / one man crisis (false- can you see why?)

 

Example of a program run:

Enter a phrase:
> Clint Eastwood 
Enter another phrase:
>Old west Action! 
true

 

 

TEST CASES:

This file contains test cases to run your code on when you have it working. Most of the code has been written- you can finish implementing it and use it to fully test your SuperAnagram code. NOTE: do not submit this class to OWL. This is for your testing purposes only. If your code passes all of these tests your code is likely to get max points.

SuperAnagram Test Cases

 

PROJECT REQUIREMENTS:

 

  1. Your classes must be calledSuperAnTester, andSuperAnagram.
  2. YourSuperAnTesterclass must prompt the user to enter each phrase. It must use aScannerobject to read in the input phrases.
  3. Your program must either print true, if the superanagram relationship is satisfied, or false if it isn't. All console Input and Output must be done by theSuperAnTesterclass.
  4. YourSuperAnagramclass must have anisSuperAnagrammethod that returnsbooleanand takes twoStringparameters- the phrases to be tested. YourisSuperAnagrammethod must returntrueif the superanagram relationship is satisfied,false, if it isn't.
  5. YourSuperAnTesterclass must create an instance of theSuperAnagramclass and call itsisSuperAnagrammethod to determine if the input satisfies the superanagram relationship.
  6. YourSuperAnagramclass must use the default constructor (no parameters) only.
  7. You mayNOTimport and use theArrayListclass for this project. Major point deduction for this. Note that you do want to use one or more arrays in this project.

 

Some tips:

  1. Remember to use thenextLinemethod, rather thannext, since spaces may be present in the two phrases that are submitted.
  2. Use theStringmethodstoLowerCaseand, possibly,toCharArray. (Consult the Java API).
  3. Punctuation and any characters other than letters a-z are ignored.
  4. For some useful background on characters and how to work with them, watch the movies in the textbook at the ends of section 4.1 and 7.1.
  5. Very important: suppose you have two arrays of characters such that the first is purported to be an embedded anagram of the second, in the sense we've described above. How can you tell? The single most important thing to do, before you write a single line of code, is to work out a paper and pencil algorithm that distinguishes between superanagrams and non-superanagrams.
  6. Algorithm Idea #1: make a scoreboard for the letters a to z. Every time you encounter a letter in the second String, up its count by 1; Then, every time you encounter a letter in the first String, lower its count by 1. Accept if the scoreboard ends up with all entries >= 0. (of course make sure you understand why this is - use pencil and paper to convince yourself!!).
  7. Algorithm Idea #2: convert strings to arrays. March down first array (representing the first string). When you encounter a letter, look for it in the second array. If you find it, blank out the occurrence in the second array; if you don't find it - it's not a super anagram. When you're all done, you've got a superanagram if your search in the second array never goes bad.
  8. Run all of the test cases provided on your solution. You can write code to use the arrays to test your SuperAnagram class. Follow the pseudocode provided. Note that this is an optional suggestion.

Answers

(5)
Status NEW Posted 12 Jan 2018 01:01 PM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)