forked from ChicoState/tippitytappity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
41 lines (32 loc) · 1.05 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <math.h>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main(){
const string phrase = "The quick brown fox jumps over the lazy dog";
string input;
do{
cout << "Type the following phrase and then press return:\n"
<< phrase << endl;
getline(cin,input);
double numPhrase = phrase.length();
double numInput = input.length();
if (input == phrase) {
cout << "Results: 100% accurate" << endl;
} else if (phrase.length() == input.length()){
double results = (numInput/numPhrase * 100);
cout << "Results: " << std::floor(results) << "% accurate" << endl;
} else {
int diff = phrase.length() - input.length();
diff = diff*2;
cout << "Results: " << 100-diff << "% accurate" << endl;
}
do{
cout << "Try again? (yes/no)\n";
getline(cin,input);
}while( input != "yes" && input != "no" );
}while( input == "yes" );
return 0;
}