diff --git a/Screening-Assignment/iamanullahmahmood.cpp b/Screening-Assignment/iamanullahmahmood.cpp new file mode 100644 index 0000000..eb157ad --- /dev/null +++ b/Screening-Assignment/iamanullahmahmood.cpp @@ -0,0 +1,93 @@ +// iamanullahmahmood@gmail.com + +/* + Program Name: Typing Speed Calculator + Author: Amanullah Mahmood + Date: Sat, 5 September 2020 +*/ + +#include +#include +#include +#include +#include + +using namespace std; + +int main() { + + string lines[1396]; + int totalCharactersTyped = 0; + time_t totalTypingTime = 0; + + // Read from the text file if exists. + ifstream sampleTextFile("shakespeare.txt"); + if(!sampleTextFile) + { + cout<<"Couldn't open the file"<::max(),'\n'); + + // Showing random sentences to a user + // Reading user input + // Calculating time and character + for (int i = 0; i < 5; i++) + { + srand(time(0)); + int line = rand() % 1396; + cout<((static_cast(totalCharactersTyped)/totalTypingTime)*60) << " characters/min.\n"; + cout << "=====================================================\n"; + + // Close the file + sampleTextFile.close(); +} + +/* +CREDIT +LINE 23 - Reading from text: +https://stackoverflow.com/questions/11546177/how-to-read-lines-of-text-from-file-and-put-them-into-an-array +LINE 43 - Skip Enter: +https://stackoverflow.com/questions/903221/press-enter-to-continue +LINE 51 - Generating Random Number +http://www.cplusplus.com/reference/cstdlib/rand/ +LINE 55 - Calculating Time +https://github.com/regstrtn/cool-codes/blob/master/measure-time-cpp.cpp +LINE 57 - Reading from console +https://stackoverflow.com/questions/18786575/using-getline-in-c +*/ + +/* +ASSUMPTION +User will write sentences without any error. +*/