Question

C++: Imagine you are developing a software package that requires users to enter their own passwords....

C++: Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: -The password should be at least six characters long. You can set the maximum size and let the user know -The password should contain at least one uppercase and at least one lowercase letter. -The password should have at least one digit. Write a program that asks for a password into a c-string and then verifies that it meets the stated criteria. If it doesn’t, the program should display a message telling the user why.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:-

#include <iostream>
#include <cstdlib>
using namespace std;
void verification(bool& try_newpassword, char& verify1, char& verify2, char& verify3, char& verify4, char& character);
int main(){
int count=0;
char password, verify1 = 'n', verify2 = 'n', verify3 ='n', verify4 ='y', character ='n';
bool try_newpassword;
cout << "Please enter your password:\n";
verification(try_newpassword, verify1, verify2, verify3, verify4, character);
while (try_newpassword == true){
cout << "Please enter another password for verification.\n";
verification(try_newpassword, verify1, verify2, verify3, verify4, character);
}
char wait;
cin >> wait;
return 0;
}
void verification(bool& try_newpassword, char& verify1, char& verify2, char& verify3, char& verify4, char& character){
char password;
int count;
do{
cin.get(password);
if (isupper(password))
verify1 = 'y';
if (islower(password))
verify2 = 'y';
if (isdigit(password))
verify3 = 'y';
if (isalpha(password))
verify4 = 'y';
else
character = 'y';
count ++;
}while (password != '\n');
if ((verify1 == 'y' && verify2 == 'y') && (verify3 == 'y' && character == 'y') && (count >= 12)){
{
cout << "This password looks pretty good.\n";
}
try_newpassword = false;
}
else
{
if (verify1 == 'n')
cout << "Your password does not have at least one uppercase letter." << endl;
if (verify2 == 'n')
cout << "Your password does not have at least one lowercase letter." << endl;
if (verify3 == 'n')
cout << "Your password does not have at least one digit."<< endl;
if (character == 'n')
cout << "Your password does not have at least character that is neither"
"a letter nor a number." << endl;
if (count > 6)
cout << "Your password should be at least 6 characters long."<< endl;
try_newpassword = true;
}
return;
}

Output:-

Add a comment
Know the answer?
Add Answer to:
C++: Imagine you are developing a software package that requires users to enter their own passwords....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...

  • How do I format this into C++? This the prompt: Design a class named Password that...

    How do I format this into C++? This the prompt: Design a class named Password that stores a password in a c-string and has member functions to test if the password complies with certain requirements as follows: The password should be between 6 and 20 characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. The password should have at least one punctuation character. Define a...

  • in C++, Design a program that asks the user to enter a password, and then analyze...

    in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...

  • A company‘s computer system requires passwords  to be 7 to 9 characters long, and ...

    A company‘s computer system requires passwords  to be 7 to 9 characters long, and  to consist of uppercase and lowercase letters {A, a, B, b, C, c, . . . , Z, z}, digits {0, 1, 2, 3, . . . , 9} and the special characters {&, #, $, *, +, _}, and  to contain at least one special character or digit. How many such passwords are there?

  • Write a program that asks the user to enter a password, and then checks it for...

    Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...

  • FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java....

    FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java. Include these steps: Write an application that provides the criteria for a strong password, and accepts a user's password from an input dialog box. If the entered password is less than six characters, more than 10 characters, or does not contain at least one uppercase letter and one digit, prompt the user to enter again. When the user's entry meets all the password requirements,...

  • Good evening, I've been toiling around with restructuring a program which is supposed to register a...

    Good evening, I've been toiling around with restructuring a program which is supposed to register a preexisting input file, which contains four different passwords, and have it pass through the verification process, to see which of those passwords meets all the criteria set by the highlighted parameters. The code stipulates that in order for a password to be considered valid, it should contain a minimum of 6 characters in total, at least 2 lowercase letter, at least 1 uppercase letter,...

  • Write a program that inputs a string from the user representing a password, and checks its...

    Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...

  • Please make this Python code execute properly. User needs to create a password with at least...

    Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY. def policy(password): digit = 0 upper = 0 lower = 0 symbol = 0 length = 0 for i in range(0, len(password)): if password[i].isdigit(): # checks...

  • I need the answer a, b, c. you have to annwer part C must a) A...

    I need the answer a, b, c. you have to annwer part C must a) A password must be 8 characters long and contain only digits and lowercase English letters. How many different passwords contain at least one digit and at least one letter? b) How many different strings of length 10 containing only the letters a, b, and c start or end with a c? c) How many people must be selected to make sure 20 of them were...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT