using namespace std; // Access cout, endl, cin without using std:: as prefix // 8 global variables and 7 prototypes of functions
string pw; // global pw for the password to be checked bool r1, r2, r3, r4, r5, r6, r7; // global 7 boolean flags for violations void s1(); void s2(); void s3(); void s4(); void s5(); void s6(); void s7(); // 7 prototypes of functions to be defined after main()
int main() // like a driver to call those 7 functions to check a password { // begin of main // must return integer to the caller cout << "Welcome to the PASSWORD game designed by Joel!" << endl; cout << "Please enter a password:" << endl; getline(cin, pw); // pw may have blanks anywhere, so must use getline( ) cout << "Your password \"" << pw << "\" " ;
while (pw != "quit") // the password is not “quit” { //begin of while loop s1(); s2(); s3(); s4(); s5(); s6(); s7(); // call to check all 7 rules for satisfaction/violation
{ // begin print all the violated rules in detail ================. cout << "violates the following rule(s):" << endl ;
// You must complete all the following strings
if (!r1) cout << "Rule 1: Length invalid – The length of the password must --- if (!r2) cout << "Rule 2: No Space – The password must not contain any space --- if (!r3) cout << "Rule 3: At least 2 digits – The password must --- if (!r4) cout << "Rule 4: At least 1 upper-case letter – The password must --- if (!r5) cout << "Rule 5: At least 1 lower-case letter – The password must --- if (!r6) cout << "Rule 6: At least 1 special character – The password must -- if (!r7) cout << "Rule 7: No special numbers – The password must not contain --- } // end print all the violated rules in detail =====================.
cout << "Please enter a password:" << endl; getline(cin, pw); // pw may have blanks anywhere, so must use getline( ) cout << "Your password \"" << pw << "\" "; } // end of while loop ==============================================.
cout << "is to quit the game." << endl; cout << "Thank you for playing the PASSWORD game designed by Joel!"; return 0 ; // return integer 0 to show the job is well done now. } // end of main =========================================================.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.