ScrabbleScorer

ScrabbleScorer - import java.util.Scanner; public class...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; public class ScrabbleScorer { private static int[] scores = new int[]{ 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}; private static String alphabet = "abcdefghijklmnopqrstuvwxyz"; public static void main( String[] args ) { Scanner console = new Scanner( System.in ); char doubleLetter = ' '; char tripleLetter = ' '; System.out.println( "What word?" ); String word = console.next(); System.out.print( "Is there a double letter? " ); boolean isDoubleLetter = parseAnswer( console.next() ); if( isDoubleLetter ) { System.out.print( "Which Letter? " ); doubleLetter = console.next().charAt( 0 ); } System.out.print( "Is there a triple letter? " ); boolean isTripleLetter = parseAnswer( console.next() ); if( isTripleLetter ) { System.out.print( "Which Letter? " ); tripleLetter = console.next().charAt( 0 ); } int score = 0; for( int i = 0; i < word.length(); i++ ) { char curLetter = word.charAt( i );
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/19/2009.

Page1 / 2

ScrabbleScorer - import java.util.Scanner; public class...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online