Question

C++ Loops homework Prompt the user for a desired password, input the password. Your program may...

C++ Loops homework

Prompt the user for a desired password, input the password.

Your program may assume without checking that there is no input failure and that

the password contains no white space.

Let's say the rules for a legal password are:

# chars must be in [4, 8]

# digs must be >= 2

The password must contain at least one letter of each case

The password must contain at least one char that's not a letter or digit

An example run of your program might go as

What password do you want? Blah00!

good password

Another run might go as

What password do you want?: A.b8x

bogus password, you're probably a criminal

Prompt the user, input as many unsigneds as the user want to type.

When the user types a non-# or a 0, terminate the program.

For each positive # the user types, output all the (positive) factors of that number.

(As usual, disregard the possibility that the user will type a negative number or a

number with a fractional part.)

An example run of your program might go as

Type #'s, 0 or non-# to quit:

12

1 2 3 4 6 12

100

1 2 4 5 10 20 25 50 100

1

1

101

1 101

blah

  

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

thanks for the question, here is the 2 program in C++

===========================================================================================

#include<iostream>

using namespace std;

bool validatePassword(const string password){

               

                if(password.length()<4 || password.length()>8){

                                return false;

                }

                int lowerCaseCount=0, upperCaseCount=0, digitCount=0, nonAlphaNumericCount=0;

                for(int index=0;index<password.length();index++){

                                char letter = password.at(index);

                                if('0'<=letter && letter<='9')digitCount++;

                                else if('a'<=letter && letter<='z')lowerCaseCount++;

                                else if('A'<=letter && letter<='Z')upperCaseCount++;

                                else nonAlphaNumericCount++;

                }

                return digitCount>=2 && lowerCaseCount>=1 && upperCaseCount>=1 && nonAlphaNumericCount>=1;

               

}

int main(){

               

                string password;

                cout<<"Enter password: ";

                cin>>password;

                bool isValid = validatePassword(password);

                if(isValid){

                                cout<<"Good Password !";

                }else{

                                cout<<"Bogus Password, you're probably a criminal";

                }

}

=========================================================================

#include<iostream>

using namespace std;

int main(){

               

                int number;

                cout<<"Type #'s, 0 or non-# to quit: ";

                while(true){

                                cin>>number;

                                if(cin.fail()){

                                                break;

                                }else if(number==0){

                                                break;

                                }

                                for(int factor=1;factor<=number;factor++)

                                if(number%factor==0)cout<<factor<<" ";

                                cout<<endl;

                }

}

=========================================================================

Add a comment
Know the answer?
Add Answer to:
C++ Loops homework Prompt the user for a desired password, input the password. Your program may...
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
  • Create a Python Program that will ask the user for a password (use input) Verify that...

    Create a Python Program that will ask the user for a password (use input) Verify that the password meets the following conditions: -must be 12 characters long -must have uppercase and lowercase -must contain at least 1 special character (!~#$%^&*{}+_) -must be a mix of numbers and letters You must do this only using regular expressions so for instance this will not be accepted if len(password) <12: At the end of the program tell the user their password is ok...

  • Create a Python Program that will ask the user for a password (use input) Verify that...

    Create a Python Program that will ask the user for a password (use input) Verify that the password meets the following conditions: -must be 12 characters long -must have uppercase and lowercase -must contain at least 1 special character (!~#$%^&*{}+_) -must be a mix of numbers and letters You must do this only using regular expressions so for instance this will not be accepted if len(password) <12: At the end of the program tell the user their password is ok...

  • 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,...

  • 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...

  • 4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lo...

    4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lowercase letter, uppercase letter, or digit from 0-9, and must contain 10 characters, how many possible passwords are there if no character can be used more than once? Express your answer as a factorial statement. Is 8 an example of permutations or combinations? b. 4: A certain computer program is accessed by entering a user-defined password. If the password a. can...

  • 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...

  • 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...

  • 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...

  • Your program must prompt the user to enter a string. The program must then test the...

    Your program must prompt the user to enter a string. The program must then test the string entered by the user to determine whether it is a palindrome. A palindrome is a string that reads the same backwards and forwards, such as "radar", "racecar", and "able was I ere I saw elba". It is customary to ignore spaces, punctuation, and capitalization when looking for palindromes. For example, "A man, a plan, a canal. Panama!" is considered to be a palindrome....

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