Eric Roberts Handout #32CS 106A February 1, 2010Section Handout #4String Processing1. Scrabble scoring (Chapter 8, exercise 5, page 286)In most word games, each letter in a word is scored according to its point value, which isinversely proportional to its frequency in English words. In Scrabble, the points areallocated as follows:Points Letters1A, E, I, L, N, O, R, S, T, U2 D, G3 B, C, M, P4 F, H, V, W, Y5 K8 J, X10 Q, ZFor example, the Scrabble word FARM is worth 9 points: 4 for the F, 1 each for the A andthe R, and 3 for the M. Write a ConsoleProgram that reads in words and prints out theirscore in Scrabble, not counting any of the other bonuses that occur in the game. Youshould ignore any characters other than uppercase letters in computing the score. Inparticular, lowercase letters are assumed to represent blank tiles, which can stand for anyletter but which have a score of 0.2. Adding commas to numeric strings (Chapter 8, exercise 13, page 290)When large numbers are written out on paper, it is traditional—at least in the UnitedStates—to use commas to separate the digits into groups of three. For example, thenumber one million is usually written in the following form:1,000,000To make it easier for programmers to display numbers in this fashion, implement amethodprivate String addCommasToNumericString(String digits)that takes a string of decimal digits representing a number and returns the string formedby inserting commas at every third position, starting on the right. For example, if youwere to execute the main programpublic void run() { while (true) { String digits = readLine("Enter a numeric string: "); if (digits.length() == 0) break; println(addCommasToNumericString(digits)); }}your implementation of the addCommasToNumericString method should be able toproduce the following sample run:– 2 –AddCommasEnter a number: 1717Enter a number: 10011,001Enter a number: 1234567812,345,678Enter a number: 999999999999,999,999Enter a number: 3. Deleting characters from a stringWrite a methodpublic String removeAllOccurrences(String str, char ch)that removes all occurrences of the character ch from the string str. For example, yourmethod should return the values shown:removeAllOccurrences("This is a test", 't') returns "This is a es"removeAllOccurrences("Summer is here!", 'e') returns "Summr is hr"removeAllOccurrences("---0---", '-') returns
View Full Document