Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my computer science course. I do not know why there is no response at all once I input data into char

I need help with my computer science course.

I do not know why there is no response at all once I input data into char passWord array.

image text in transcribed

Below is my code:

#include

#include

#include

using namespace std;

bool testPassWord(char[]);

int countLetters(char*);

int countDigits(char*);

int main()

{

int numLetters, numDigits;

char passWord[20];

cout

cin.getline(passWord,20);

if(testPassWord(passWord))

cout

else

cout

numLetters = countLetters(passWord);

numDigits = countDigits(passWord);

cout

cout

return 0;

}

bool testPassWord(char custPass[])

{

int numLetters, numDigits, length;

length = strlen(custPass);

numLetters = countLetters(custPass);

numDigits = countDigits(custPass);

if (numLetters == 5 && numDigits == 3 && length == 8 )

return true;

else

return false;

}

int countLetters(char *strPtr)

{

int occurs = 0;

while(*strPtr != '\0')

{

if (isalpha(*strPtr))

{

occurs++;

strPtr++;

}

}

return occurs;

}

int countDigits(char *strPtr)

{

int occurs = 0;

while(*strPtr != '\0')

{

if (isdigit(*strPtr))

{

occurs++;

strPtr++;

}

}

return occurs;

}

Enter a password consisting of exactly 5 letters and 3 digits: kayle123

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago