/*
Connor Williams
Williams6.cpp
CSC1610
This is a program that will add the integer values of a string, mod them by 64 then output the catagorey of the number
*/
#include <iostream>
#include <string>
#include <cctype>
usingnamespace std;
enum IntDesignation {perfect, deficient, abundant};
//Prototype
int checkSum(string word);
IntDesignation catString(int sum);
int main()
{
string word;
int sum;
cout <<"Please enter a string"<<endl;
cin >> word;
while (word != "exit")
{
sum = checkSum(word);
cout <<"The checksum is "<<sum<<", which is "<<catString(sum)<<"."<<endl;
cout <<"Please enter a string"<<endl;
cin >> word;
}
return 0;
}
int checkSum(string word)
{
int sum=0;
int n = word.length();
for (int i = 0;i<n;i++)
{
int c = (char) word.at(i);
sum += c;
}
sum %= 64;
return sum;
}
IntDesignation catString(int sum)
{
int check = 0;
for (int x=0;x<sum/2;x++)
{
if (sum%x==0)
check = check + x;
}if (check<sum)
cout<<"deficient";
if (check==sum)
cout<<"perfect";
if (check>sum)
cout<<"abundant";
}