Can anyone help me solve with this C++ Computer Science question? I am strugglin
ID: 3735982 • Letter: C
Question
Can anyone help me solve with this C++ Computer Science question? I am struggling to understand.
Create a function to ask for a person's first name, middle name, and last names via user input. Store all three names in three separate character arrays. The write the program to store the person's name arranged in the format: user last name continued by a comma and one space, followed-up through the user first name and one space, and finishing with user middle name. (i.e. Assume the user input is "Holly May Joestar", it should store Joestar, Holly May created in the 4th array. Once completed, print all results from 4th array to the computer screen. Make your 4th array as large as necessary to hold the name.
Part 2) Make one function that will prompt the user for a password and confirm that it will pass the criteria. If it fails to meet requirements, construct a message that will display a specific error conveying what was incorrect.
Part 3.) Merge both functions through a single driver program to check that your functions perform correctly.
Password Criteria:
Password must be 6 and 14 characters
The password has to consist of a single uppercase and a single lowercase character.
The password must have at least 1 digit.
The password has to contain at least 1 punctuation character (. , ! ; : " ' * ()...etc)
Explanation / Answer
PRINTING NAMES-------- // This function will simply take inputs as names and print the names in the desired format.
void Name( string first , string middle , string last)
{
cout<<last<<","<<" "<<first<<" "<<middle;
}
PASSWORD VALIDATION------ // This function will check for the valid password as per the mentioned criteria.
void checkPassword( char password[])
{
int n = strlen(password);
int c1,c2;
c1=0,c2=0;
bool upper,lower,digit,special;
upper=false,lower=false,digit=false,special=false;
if(n>=6 && n<=14) {
for(i=0,i<n;i++)
{
if(islower(password[i]))
{
lower=true; c1++; }
elseif(isUpper(password[i]))
{
upper=true; c2++; }
elseif(isdigit(password[i]))
{
digit=true; }
else
special=true;
}
if((c1==1) && (c2==1) && (digit==true) && (special==true))
cout<<"Valid password";
else
cout<<"try again..!!";
}
else
cout<<"Password entered must be 6 and 14 charac
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.