#include <iostream>
using namespace std;
int ScrabbleScore(string word)
{
int x=0;
for(int index =0; index < (int)word.length() -1; index ++)
{
char ltr = toupper(word[index]);
if(ltr == 'A' || ltr == 'E' || ltr == 'I' || ltr == 'L' || ltr == 'N' || ltr == 'O' || ltr == 'R' || ltr == 'S' || ltr == 'T' || ltr == 'U')
x=x+1;
else if(ltr == 'D' || ltr == 'G')
x=x+2;
else if(ltr == 'B' || ltr == 'C' || ltr == 'M' || ltr == 'P')
x=x+3;
else if(ltr == 'F' || ltr == 'H' || ltr == 'V' || ltr == 'W' || ltr == 'Y')
x=x+4;
else if(ltr == 'K')
x=x+5;
else if(ltr == 'J' || ltr == 'X')
x=x+8;
else(ltr == 'Q' || ltr == 'Z');
x=x+10;
}
return x;
}
int main()
{
string scrab;
string atsym = "@";
cout << "This program tests the ScrabbleScore function." << endl;
cout << "Enter word, ending with " << atsym << "." << endl;
cout << "Word: ";
cin >> scrab;
while(!(scrab == "@"))
{
cout << "The basic score for '" << scrab << "' is " << ScrabbleScore(scrab) << endl;
cout << "Word: ";
cin >> scrab;
}
}
Can anyone tell me when the character 'A' is entered my function returns 0 and not 1?
It will not return anything but 0.