This is supposed to generate a password, but It is not displaying the way it is supposed to display, can someone please look at my code and let me know why it is not printing out
Enter 5 character string: hapPy
Password is: jAaRY
Press any key to continue_
This is my code:
#include <iostream> // required to perform C++ stream I/O
#include <string> // required to access string functions
using namespace std; // for accessing C++ Standard Library members
// function main begins program execution
int main()
{
// define variables
string plainText; // stores user input
char password; // contain password character
// prompt user for five character string
cout << "\nEnter five-character string: ";
getline( cin, plainText );
// display error message if five characters are not entered
if ( plainText.size() < 5 )
{
// display error message
cout << "\nError: You must enter a name\n" << endl;
} // end if
else // otherwise, do calculations to get password
{
// display password
cout << "\nPassword is: " << static_cast<char>(plainText.at( 4 ) - 15)
<< static_cast<char>(plainText.at( 3 ) - 15)
<< static_cast<char>(plainText.at( 2 ) - 15)
<< static_cast<char>(plainText.at( 1 ) - 15)
<< static_cast<char>(plainText.at( 0 ) - 15)
<< endl << endl;
cin >> password; // stores the character to password
} // end else
return 0; // indicate that program ended successfully
} // end function main