i wrote a code for cs50. My task was to create a scrabble game. everything worked fine with lower case letters but when i tried upper case letter the value the computer returned to me was always the same 0. I tried to fix it on my own but i only made it worse. i would appreciate it if someone could tell me how.
// Points assigned to each letter of the alphabet
int POINTS[] = {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};
int compute_score(string word);
int main(void)
{
// Get input words from both players
string word1 = get_string("Player 1: ");
string word2 = get_string("Player 2: ");
// Score both words
int score1 = compute_score(word1);
int score2 = compute_score(word2);
printf("Score for Player 1: %i\n", score1);
printf("Score for Player 2: %i\n", score2);
// Print the winner
if (score1 == score2)
{
printf("Tie! \n");
}
if (score1 < score2)
{
printf("Player 2 wins! \n");
}
if (score1 > score2)
{
printf("Player 1 wins! \n");
}
}
int compute_score(string word)
{
// Compute and return score for string
int compute_score = 0;
int numb;
for (int i = 0, n = strlen(word); i < n; i++)
{
if(isupper(word[i]))
{
numb = word[i] - 65;
numb = POINTS[numb];
}
if(islower(word[i]))
{
numb = word[i] - 97;
numb = POINTS[numb];
}
else
{
numb = 0;
}
compute_score += numb;
}
return compute_score;
}