Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <chrono>
- using namespace std;
- int main()
- {
- string text;
- string quote="Perhaps if you know you are insane then you are not insane.";
- float wordCount=1;
- for(int c=0;c<quote.length();c++)if(quote[c]==' '&"e[c+1]!=' ')wordCount++;
- cout<<quote<<endl;
- for(int c=3;c>0;c--)
- {
- cout<<c;
- Sleep(1000);
- system("cls");
- cout<<quote<<endl;
- }
- auto start=chrono::high_resolution_clock::now();
- getline(cin,text);
- auto finish=chrono::high_resolution_clock::now();
- chrono::duration<double>elapsed=finish-start;
- float time=elapsed.count();
- bool acc=false;
- if(text==quote)acc=true;
- if(acc==true)
- {
- float wpm=(wordCount/time)*60;
- float cpm=wpm*5;
- cout<<"Your time was: ";
- printf("%.2f",time);
- cout<<" seconds."<<endl;
- cout<<"That's ";
- printf("%.0f",wpm);
- cout<<" words per minute! (";
- printf("%.0f",cpm);
- cout<<" CPM).";
- }
- if(acc==false)cout<<"You made a mistake. Restart the program and try again.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement