Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java with program screenshot of code and output please In the game of Scrabble, players create words on a crossword puzzle grid using letter

in java with program screenshot of code and output please
image text in transcribed
image text in transcribed
In the game of Scrabble, players create words on a crossword puzzle grid using letter tiles. Each letter the has a value: Players can also use a blank tile (worth 0 points) to substitute for any letter. The score for a word is the sum of the values of the letter tiles. 1. Write a simple Java program that prompts the user to enter a word and outputs the Scrabble score for that word, based on the point values of the letters only. A blank tile should be entered as an asterisk (*). For this part, you may assume that the input word is valid and consists of only lowercase letters. In your solution, you should include a method that returns the Scrabble point value of a given character. If the character is not a letter, return 0 . Try to write your method so you don't test for each letter individually, using an If or switch statement. HINT: Set up an array to hold all of the letter scores, and then use the position of each letter in the alphabet to extract out the corresponding score from the array. If you store the letters of the alphabet in a string as we did in lecture, you can use the indexof method on this string to get the position of any letter of the alphabet. To initialize an array directly, you can use the syntax illustrated in the example below: int[]data={1,3,2,7,4}; To access the array, simply use the array name and a subscript in square brackets. For example, the following code adds up the integers in the data array declared above: int sum =; for (int i=0;i += data[i]; Test your code to see that it works correctly before moving on. Sample tests: Test your code to see that it works correctly before moving on. Sample tests: 2. The game also has bonus points. If a tile is placed on one of the following four spaces, the player earns a bonus: - DOUBLE LETTER SCORE - The point value of that letter is doubled. - TRIPLE LETIER SCORE - The point value of that letter is tripled. - DOUBLE WORD SCORE - The total value of the word is doubled. - TRIPLE WORD SCORE - The total value of the word is tripled. Also, if the word is 7 or more letters, an additional 50 points is added to the score after all other bonuses are computed. Modify your program so that it updates the total score for bonuses. You may assume that there is at most one double letter score and one triple letter score. You may also assume there is at most one double or triple word score (but not both). Prompt the user as follows: Is there a DOUBLE LETTERISCORE? [y] y Which letter? e Is there a TRIPLE LETTER SCORE? [y]n Is there a DOUBLE WORD SCORE? [y] y Note that since there is a double word score, the program does not prompt for a triple word score. You may assume for this part that the user input is always valid. Derive a set of test cases to use that will execute all possible paths through your code that computes bonuses. In a comment in your program, write in the number of different execution paths there are in this part of the program, Test your program thoroughly with the test cases you derlved

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Patients are charged premiums based on their risk rating.

Answered: 1 week ago

Question

Bismarck countries have all had universal insurance for at least

Answered: 1 week ago