Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / This prrogram a password for the American Equities / / web page to see if the format is correct / / Place Your
This prrogram a password for the American Equities
web page to see if the format is correct
Place Your Name Here
#include
#include
#include
using namespace std;
function prototypes
bool testPassWordchar;
int countLetterschar;
int countDigitschar;
int main
char passWord;
cout "Enter a password consisting of exactly
"letters and digits:" endl;
cin.getlinepassWord;
if testPassWordpassWord
cout "Please wait your password is being verified" endl;
else
cout "Invalid password. Please enter a password
"with exactly letters and digits" endl;
cout "For example, myRuN is valid" endl;
Fill in the code that will call countLetters and
countDigits and will print to the screen both the number of
letters and digits contained in the password.
return ;
Lesson A
testPassWord
task: determines if the word in the
character array passed to it contains
exactly letters and digits.
data in: a word contained in a character array
data returned: true if the word contains letters &
digits, false otherwise
bool testPassWordchar custPass
int numLetters, numDigits, length;
length strlencustPass;
numLetters countLetterscustPass;
numDigits countDigitscustPass;
if numLetters && numDigits && length
return true;
else
return false;
the next functions are from Sample Program
countLetters
task: counts the number of letters both
capital and lower casein the string
data in: a string
data returned: the number of letters in the string
int countLetterschar strPtr
int occurs ;
whilestrPtr
if isalphastrPtr
occurs;
strPtr;
return occurs;
continues
LESSON Characters and Strings
countDigits
task: counts the number of digits in the string
data in: a string
data returned: the number of digits in the string
int countDigitschar strPtr
int occurs ;
whilestrPtr
if isdigitstrPtr isdigit determines if
the character is a digit
occurs;
strPtr;
return occurs;
Exercise : Fill in the code in bold and then run the program several times
with both valid and invalid passwords. Read through the program and
make sure you understand the logic of the code.
Exercise : Alter the program so that a valid password consists of characters, of which must be digits and the other letters.
Exercise : Adjust your program from Exercise so that only lower case
letters are allowed for valid password
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started