my first cs2250 project. A bit more code than those cs1250 projects.
Code
#include <iostream>
#include <string>
using namespace std;
void firstDec(string passedstring, int pos);
string inputHandler(string &initial);
int decCheck(string passedstring, int pos);
int decCheck2(string passedstring, int pos);
void secondDec1(string passedstring, int pos);
void secondDec2(string passedstring, int pos);
int main()
{
string initial, compare, passedstring;
int dec, pos, dec2;
getline(cin, initial, 'Q');
while (initial != compare)
{
passedstring = inputHandler(initial);
pos = int(passedstring.find(" "));
dec = decCheck(passedstring,pos);
if(dec == 1)
{
firstDec(passedstring, pos);
cout << "\n";
}
else if (dec == 2)
{
dec2 = decCheck2(passedstring,pos);
if (dec2 == 1)
{
secondDec1(passedstring, pos);
cout << "\n";
}
else if (dec2 == 2)
{
secondDec2(passedstring, pos);
cout << "\n";
}
}
}
return 0;
}
void firstDec(string passedstring, int pos)
{
string string1, string2, stem;
int len, len1;
len = int(passedstring.length());
string1 = passedstring.substr(0,pos);
string2 = passedstring.substr(pos+1,len-pos);
len1 = int(string2.length());
stem = string2.substr(0,len1-2);
cout << "Nom " << string1 << " " << string2 << endl;
cout << "Gen " << stem+"ae" << " " << stem+"arum" << endl;
cout << "Dat " << stem+"ae" << " " << stem+"is" << endl;
cout << "Acc " << stem+"am" << " " << stem+"as" << endl;
cout << "Abl " << stem+"a" << " " << stem+"is" << endl;
}
void secondDec1(string passedstring, int pos)
{
string string1, string2, stem;
int len, len1;
len = int(passedstring.length());
string1 = passedstring.substr(0,pos);
string2 = passedstring.substr(pos+1,len-pos);
len1 = int(string2.length());
stem = string2.substr(0,len1-1);
cout << "Nom " << string1 << " " << string2 << endl;
cout << "Gen " << stem+"i" << " " << stem+"orum" << endl;
cout << "Dat " << stem+"o" << " " << stem+"is" << endl;
cout << "Acc " << stem+"um"<< " " << stem+"os" << endl;
cout << "Abl " << stem+"o" << " " << stem+"is" << endl;
}
void secondDec2(string passedstring, int pos)
{
string string1, string2, stem;
int len, len1;
len = int(passedstring.length());
string1 = passedstring.substr(0,pos);
string2 = passedstring.substr(pos+1,len-pos);
len1 = int(string2.length());
stem = string2.substr(0,len1-1);
cout << "Nom " << string1 << " " << string2 << endl;
cout << "Gen " << stem+"i" << " " << stem+"orum" << endl;
cout << "Dat " << stem+"o" << " " << stem+"is" << endl;
cout << "Acc " << stem+"um"<< " " << stem+"a" << endl;
cout << "Abl " << stem+"o" << " " << stem+"is" << endl;
}
string inputHandler(string &initial)
{
string passedstring;
int pos;
pos = int(initial.find('\n'));
passedstring = initial.substr(0,pos);
initial.erase(0,pos+1);
return passedstring;
}
int decCheck(string passedstring,int pos)
{
int fdcheck;
fdcheck = int(passedstring.find("ae", pos));
if (fdcheck > 0)
{
return 1;
}
else return 2;
}
int decCheck2(string passedstring, int pos)
{
int check1, check2, len;
string first;
first = passedstring.substr(0,pos);
len = int(first.length());
check1 = int(first.find("r", len-2));
check2 = int(first.find("us", len-2));
if (check1 > 0 || check2 > 0)
{
return 1;
}
else return 2;
}