diff --git a/1-ConsecutiveHeads/ConsecutiveHeads.pro b/1-ConsecutiveHeads/ConsecutiveHeads.pro index 85bdbce..4570e8d 100644 --- a/1-ConsecutiveHeads/ConsecutiveHeads.pro +++ b/1-ConsecutiveHeads/ConsecutiveHeads.pro @@ -110,7 +110,7 @@ win32 { QMAKE_LFLAGS += -Wl,--stack,536870912 LIBS += -lDbghelp LIBS += -lbfd - LIBS += -liberty +# LIBS += -liberty LIBS += -limagehlp } macx { diff --git a/1-ConsecutiveHeads/src/ConsecutiveHeads.cpp b/1-ConsecutiveHeads/src/ConsecutiveHeads.cpp index 4b7f6b3..883dbe2 100644 --- a/1-ConsecutiveHeads/src/ConsecutiveHeads.cpp +++ b/1-ConsecutiveHeads/src/ConsecutiveHeads.cpp @@ -4,7 +4,42 @@ #include "random.h" using namespace std; +//initialization function prototype +int coinToss(int &numberOfMatches,int &count); + + int main() { - // TODO: fill in the code - return 0; +//Initialization of variables: the number of matches +//and a variable number of attempts + int numberOfMatches = 0; + int count = 0; + coinToss(numberOfMatches,count); + cout<<"It took "< "<0){ + if(word[0]=='e'&& word.length()==1){ + str +=word[0]; + } + else if(isVowel(word[0])&&isVowel(word[1])){ + str = str+string("ob")+word[0] + word[1] + obenglobish(word.substr(2,word.length()-2)); + } + else if(isVowel(word[0])&&!isVowel(word[1])){ + str = str+string("ob")+ word[0] + obenglobish(word.substr(1,word.length()-1)); + } + + else if(!isVowel(word[0])&& word.length() != 1){ + str +=word[0] + obenglobish(word.substr(1,word.length()-1)); + } + else{ + str +=word[0]; + } + } + else{ + str=""; + } + return str; +} diff --git a/2-Obenglobish/src/Obenglobish.cpp.autosave b/2-Obenglobish/src/Obenglobish.cpp.autosave new file mode 100644 index 0000000..ca4b5dc --- /dev/null +++ b/2-Obenglobish/src/Obenglobish.cpp.autosave @@ -0,0 +1,83 @@ +#include +#include +#include "console.h" +#include "simpio.h" +#include "strlib.h" +using namespace std; + +bool isVowel(char letter); +string obenglobish(string word); + +int main() { + while(true){ + string word = getLine("Enter a word: "); + if(word == "")break; + string translation = obenglobish(word); + cout<< word<<" -> "<0){ + if(word[0]=='e'&& word.length()==1){ + str +=word[0]; + } + else if(isVowel(word[0])&&isVowel(word[1])){ + str = str+string("ob")+word[0] + word[1] + obenglobish(word.substr(2,word.length()-2)); + } + else if(isVowel(word[0])&&!isVowel(word[1])){ + str = str+string("ob")+ word[0] + obenglobish(word.substr(1,word.length()-1)); + } + + else if(!isVowel(word[0])&& word.length() != 1){ + str +=word[0] + obenglobish(word.substr(1,word.length()-1)); + } + else{ + str +=word[0]; + } + } + else{ + str=""; + } + return str; +} diff --git a/3-NumericConversion/NumericConversion.pro b/3-NumericConversion/NumericConversion.pro index 85bdbce..4570e8d 100644 --- a/3-NumericConversion/NumericConversion.pro +++ b/3-NumericConversion/NumericConversion.pro @@ -110,7 +110,7 @@ win32 { QMAKE_LFLAGS += -Wl,--stack,536870912 LIBS += -lDbghelp LIBS += -lbfd - LIBS += -liberty +# LIBS += -liberty LIBS += -limagehlp } macx { diff --git a/3-NumericConversion/src/NumericConversion.cpp b/3-NumericConversion/src/NumericConversion.cpp index d66d654..7ce11fe 100644 --- a/3-NumericConversion/src/NumericConversion.cpp +++ b/3-NumericConversion/src/NumericConversion.cpp @@ -1,6 +1,7 @@ #include #include #include "console.h" +#include using namespace std; // Function prototypes @@ -9,6 +10,82 @@ int stringToInt(string str); int main() { - // TODO: fill in the code +/****Testing functions intToString****/ + const int N = 10; + int numTest[N] = {2565,-2565,505,-505,50,-50,1,-1,0,0}; + for(int i=0;i #include "console.h" +#include +#include "tokenscanner.h" using namespace std; +//Function prototypes +void settingFile(); +void fleschKincaid(ifstream &infile); +int syllablesIn(string word); +bool checkVowels(char letter); +double grade(int words,int sentens,int syllables); + + int main() { - // TODO: fill in the code +settingFile(); return 0; } + +/*The function prompts the user for a filename. +Checks whether there is such a file. +If there is the object -ifstream infile-(The object read from the stream file) creates the file and +passes it to the function fleschKincaid */ +void settingFile(){ + char str[255]; + cout<<"Enter input file name: "; + if(cin.getline(str, sizeof(str))){ + ifstream infile(str,ios::in); + if(infile.is_open()){ + fleschKincaid(infile); + infile.close(); + } + else{ + cout<<"This file does not exist"< 0) { + if (letter != 'e' && !checkVowels(word[i - 1])) { + countWSyllables++; + } + } + + } + } + if (countWSyllables == 0) { + countWSyllables = 1; + } + return countWSyllables; + } + +//Determination of whether the letter is a vowel + bool checkVowels(char letter) { + if (letter == 'a' || letter == 'e' || letter == 'y' + || letter == 'i' || letter == 'u' || letter == 'o') { + return true; + } + return false; + } + +//Calculation Grade Level formula with pre-defined constants. + double grade(int words,int sentens,int syllables){ + double grade=0; + double const c0=-15.59; + double const c1=0.39; + double const c2=11.8; + grade = c0+c1*((double)words/sentens)+c2*((double)syllables/words); + return grade; + }