I'm trying to write a program to calculate the score of a word, based on the game Scrabble
The scores are based off the image above.
I've currently coded a function, my ideal goal is to use this and get the user to input a word to calculate the score.
int scrabbleScore(String Word) {
int score = 0;
for (int i = 0; i < Word.length(); i++){
char calculatedLetter = Word.at(i);
switch (calculatedLetter) {
case 'A':
case 'E':
case 'I':
case 'L':
case 'N':
case 'O':
case 'R':
case 'S':
case 'T':
case 'U':
score +=1; break;
case 'D':
case 'G':
score +=2; break;
case 'B':
case 'C':
case 'M':
case 'P':
score +=3; break;
case 'F':
case 'H':
case 'V':
case 'W':
case 'Y':
score +=4; break;
case 'K':
score +=5; break;
case 'J':
case 'X':
score +=8; break;
case 'Q':
case 'Z':
score +=10; break;
default: break;
}
}
return score;
Why is this giving me a score of 0 for any word?