// Name: Alan Helms // Class: CPT 232 C++ I // Times: MWF 9:00 - 9:50 // Semester: Spring 4-8-2003 // Project Name: PWAcc_vfx.cpp // Program Purpose: This program is a password generator and vaildator. This // allows three users to enter their last name in a 2-D array, // along with their account balances in a 1-D array. // The program randomly creats a 8-digit password and stores // it a 2-D array. After all data is entered from all three // users, the program will prompt each user to enter his or her // password. If the password is correct, their corresponding // account balances will be printed to the screen. Otherwise, // the user will be asked two more times to enter the correct // password before it moving one to the next user. // // // ****NOTE: THIS VERSION WAS CREATED WITH Microsoft Visual C++ EDITIOR**** #include using std::cin; using std::cout; using std::endl; #include using std::setprecision; using std::setiosflags; using std::setw; using std::ios; #include #include int main() { srand(time(0)); char lastName[3][20]; char turn[3][7] = { "first", "second", "third" }; double balance[3]; int passWrd[3] ={0}; int uPassW[3], correct = 0; for (int i = 0; i < 3; i++) { cout << "Enter the " << turn[i] << " user's last name. "; cin >> lastName[i]; cout << "Enter " << lastName[i] << "'s account balance $"; cin >> balance[i]; // this section of code creates the 8-digit password // and sets a section of array passWrd to the digits redendered. for (int f = 1; f < 10000000; f *= 10) passWrd[i] += (rand() % 10) * f; // this section prints the password cout << lastName[i] << "'s password is "; cout << passWrd[i] << endl << endl; } for (int h = 0; h < 3; h++) { do { cout << endl; cout << "Enter "; cout << lastName[h]; cout << "'s password. "; cin >> uPassW[h]; // validation of the passwords stored and the user supplied PW if (uPassW[h] == passWrd[h]) { cout << lastName[h] << " has a balance of $" << setiosflags(ios::fixed | ios::showpoint) << setprecision(2) // setprecision to two places beyond the decimal << balance[h] << endl << endl; correct = 3; } else { cout << "Incorrect Password. Try Again." << endl; ++correct; } } while (correct < 2); } cout << "SEE YA!!!" << endl; return 0; }