You can simplify the whole thing quite a bit to get the same values as you are getting currently.
Code
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int ch2n(string word);
int char2num(string word);
int main(){
string inputWord, phrase("Word or Sentence: ");
ofstream theFile("Info.txt", ios_base::app);
cout << phrase;
while (getline(cin, inputWord)){
if (inputWord.find_first_not_of(' ') == string::npos)return 0;
int letterValue = ch2n(inputWord);
int acrossValue = char2num(inputWord);
theFile << phrase << inputWord << endl;
theFile << "Letter Value: " << letterValue << endl;
theFile << "Across Value: " << acrossValue << endl;
theFile << "Sum: " << letterValue + acrossValue << endl;
theFile << "Difference: " << letterValue - acrossValue << endl;
theFile << "Total: " << 3 * letterValue + acrossValue << endl;
cout << phrase;
}
}
int ch2n(string word){
int total = 0;
for (int i = 0; i != word.size(); i++)
if (isalpha(word[i]))
total += tolower(word[i]) - 'a' + 1;
return total;
}
int char2num(string word){
int total = 0;
for (int i = 0; i != word.size(); i++) {
if (isalpha(word[i])) {
char c = tolower(word[i]);
if (c >= 'a' && c <= 'i') {
total += c - 'a' + 1;
} else if (c >= 'j' && c <= 's') {
total += c - 'j' + 1;
} else if (c >= 't' && c <= 'z') {
total += c - 't' + 2;
}
}
}
return total;
}
Also, what is your total line doing?
Code
theFile << "Total: " << ch2n(inputWord) + char2num(inputWord) + (ch2n(inputWord) + char2num(inputWord)) + (ch2n(inputWord) - char2num(inputWord)) << endl;
Why not just have:
Code
theFile << "Total: " << 3 * ch2n(inputWord) + char2num(inputWord) << endl;
Also, your functions and variables could use a bit more clarity, for instance: ch2n and char2num imply that they do the same thing, however they don't... maybe consider using something like "calculateAcrossValue" or "acrossValue" or something. Additionally, inputWord is not always a single word.
Lastly, and most importantly... I tried to make it through that YouTube video (please tell me that's not you), but what the hell is that guy smoking? I don't even have a single clue what he's trying to prove