interlocking words on a Scrabble board

Assignment Help Basic Computer Science
Reference no: EM13161398

The board game Scrabble works by assigning points to wooden tiles that are marked with printed letters, and are arranged as interlocking words on a Scrabble board. It's described here: Scrabble.

We'll simplify this considerably, and consider the following question. We begin with the letter-scoring scheme from Scrabble:

a = 1, b = 3, c = 3, d = 2, ..., z = 10.

Given a text file - a novel for example, what is the token in the file with the highest scoring density? Token density is calculated as follows: First, letters are assigned their scrabble score. All non-letters (e.g., period, comma, etc.) have score 0. A token's density equals the sum of the scrabble values of its characters, divided by the length of the token.

Some examples:

Token     Score
cab        7/3 = 2.33  (note: standard division, not Java integer division)
cab!       7/4 = 1.75  (token length is now 4, '!' has value 0)
zzz        30/3 = 10.0



Your solution should be in two classes, a driver class called DenseScrabbleTester, which includes main and uses Scanner to identify an external file for dense Scrabble study, and a class calledDenseScrabble, which does the heavy lifting for the application. The DenseScrabble class must extend Echo, in the way we've indicated in Chapter 10. Submit the code for these two classes in the boxes below.

Output: your program should report the (or a) highest density token in the input file, along with the density value for that token, and the line number in the file the token appeared on.

Tips:

Make sure you master Chapter 10 of the text as a prelude to doing this problem.

Here is a list from a to z of the letter scores from Scrabble:

{1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10}

Notice that this list is in proper format for copying and pasting directly into your program as an int array.

It's far easier to convert lines of text to lowercase before processing.

If you're not sure how to extract letter scores from the scrabble value array, above, you should view the short movie embedded in section 7.1 in the text.

Use the StringTokenizer constructor with just one argument (so the only delimiter is white space - punctuation should figure in the token density calculation, as it does in the "cab!" example above).

You MUST use a try-catch harness in the driver class.

You MUST comment every method with a one line description of the job that method does, and your description must be placed just below the method header line.

Some sample output:

enter file name
 sampletext.txt
winner: now   score 2.0   Line number: 1
------------------------------- 
enter file name
 HeartOfDarkness.txt
winner: buzz   score 6.0   Line number: 759 

 

 

Reference no: EM13161398

Questions Cloud

Explain the rate of consumption of nh3 : How is the rate of consumption of O2 related to the rate of consumption of NH3? (b) How is the rate of formation of NO related to the rate of consumption of NH3? (c) How is the rate of formation of H2O related to the rate of consumption of NH3?
Define u.s. plans new strategy for hiv : The Obama administration plans to unveil a new AIDS strategy Tuesday, aimed at reducing new infections and increasing the number of HIV-positive people getting care.
Explain orbital and an unpaired oxygen electron : The figure-8 bond orbitals around the carbon and oxygen atoms actually extend to infinity but do have two overlapping areas. C)This bond is the result of the interaction of an unpaired carbon electron in the 2s orbital and an unpaired oxygen elect..
What is the frequency of males hemizygous for the d allele : A) If the f(D) of an X-linked gene in a population = 0.8, what is the f(d) of the other allele at this locus?
interlocking words on a Scrabble board : The board game Scrabble works by assigning points to wooden tiles that are marked with printed letters, and are arranged as interlocking words on a Scrabble board.
create a version of a carnival game : assignment, your job is to create a version of a carnival game in which mechanical dogs race along a track. The racing game is called DogTrack. DogTrack is also the name of the java source file you must submit to complete the assignment. The DogTrack..
What are the benefits of using tangible interfaces : What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?
What are the benefits of using tangible interfaces : What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?
What are the benefits of using tangible interfaces : What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write files which do not reside at root or master directory

Provide the example of names of three files from own computer that do not reside at the root or master directory. For each file, list both therelative filename and its complete filename.

  Recognize interface metaphor to use for conceptual design

For conceptual design (architectural or high-level), recognize the interface metaphor to use, interaction type(s) to employ, and interface type(s) to follow. For each of these, make sure to describe why you select what you did.

  Study ai literature to find-task can be solved by computers

Study the AI literature to find whether or not the following tasks can presently be solved by computers. Give proper reference to support your answer.

  Explaining gui differences and security differences

With that being said, its great that each of you pointed out the GUI differences. What about the Security differences?

  Protect proprietary interest by addressing ethical issues

Advise whether you agree or disagree with CEO, specifically addressing ethical issues involved. Suppose you make a decision to hire a hacker, how would you protect your proprietary interests?

  Illustrate how compiler would unroll loop four times

Illustrate how compiler would unroll loop 4 times. Make sure to include code which compute all the pointers required for operation within each iteration. suppose that processor has as many registers as required.

  Find crc using modulo two arithmetic or polynomials

For a pattern P = 10011, and a message D = 10010011011, find, using modulo 2 arithmetic or polynomials, the CRC, then the string T to be transmitted.

  Finding vertices of polygon stored in array-clockwise order

Assume that n ≥ 3 and the n vertices of P are stored in an array in clockwise order around P. Describe how to determine efficiently whether exactly one of the points q and r falls within P. Analyze the time for your algorithm.

  Enforcing mandatory access control environment

Users dont seem to understand that they need to handle certain documents with more care and control than others. Which of the following will improve this situation?

  Function whose job is to output some sequence

Write a function whose job is to output some sequence of "interesting" #'s. The numbers should be separated from one another somehow so they don't all run together. This function may need to call another function, where the second function determines..

  Define the term solvable

What does the term solvable mean to you? What does it mean to say that "you solved a problem"? Find examples of problems for which you believe there are no solutions.

  Positive and negative characteristics of hybrid databases

A idea that several of the main database vendors have come up with is a hybrid database that integrates the concepts of both OO and Relational databases.

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