// ~cs35/string_4a.cpp

#include "CS35files.h"

int convert(char ch)
{
	int value, nnumber;
//a multibranch "if"

	if (isupper(ch))  value = int(ch) - int('A') + 1;
	else if (islower(ch))  value = int(ch) - int('a') + 1;
//add line so that '0' converts to 0; '1' to 1, etc.
	else if(isdigit(ch))   value = int(ch) - int('0');
	else if (isdigit(ch))  value = int(ch) - int('1');
	else value = 0;

	return value;
}

int main ()
{

// declare variable "slogan"
	int sum, i;
	char keystroke;
	char slogan[60];
/*	for (i = 1; i <= 3; i++)
	{
		cout <<"Enter a single keystroke (not a blank): ";
		cin >> keystroke;
		cout <<"The \"value\" of chararacter "<<keystroke<<" is ";
		
		cout <<convert(keystroke)<<endl<<endl;
	}
*/		
	cout << "Enter \"What really matters\" (e.,g., hardwork; Attitude): ";	
	getline(slogan);
	
	sum = 0;
	for (i = 0; i < strlen(slogan); i++)
	{
		keystroke = slogan[i];
		sum = sum + convert(keystroke);
	}
	cout << slogan<<" sums to "<<sum<<"%.\n";

	return 0;
}
