Question

Programming Problem 1 - File Name: pass.cpp (5 pts.)
      
Description:

You were hired by the KFU cybersecurity team to create a program that checks if the passwords chosen by users are strong or not. A password is considered strong if the following conditions are satisfied:
•   Its length is at least 8 characters
•   It contains at least one uppercase letter.

Input Format:
The program will prompt the user to enter their chosen password.

Example Input

Enter your password: Kfu123!b


Output Format
The program will display a message if the password is strong (Strong password) or not (Weak password).

Example Output

Strong password

Example Program Execution:


Note: Use the input from the screen shot above to test your program.

+ Det * Mines (14081- uded ligh * Limitadament - Google → C d ocs.google.com/document/d/1xWdBw5j7UENEKO BPWMTUGY/edit + E Sha

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

C++ CODE:

#include <iostream>
using namespace std;
int main() {
    string password;
    bool isLengthy = false, containsUppercase = false;
    // Get password from the user
    cout << "Enter your password: ";
    cin >> password;
    // Check if password is at least 8 characters long
    if (password.length() >= 8)
        isLengthy = true;
    // Check if password contain at least one uppercase letter
    for (int i = 0; i < password.length(); i++) {
        if (password[i] >= 'A' && password[i] <= 'Z') {
            containsUppercase = true;
            break;
        }
    }
    // If password is at least 8 characters long and contains an uppercase letter
    // then it is a strong password
    if (isLengthy && containsUppercase)
        cout << "Strong password\n";
    else
        cout << "Weak password\n";
    return 0;
}

OUTPUT:

shubh@ACER-NITRO MINGW64 ~/OneDrive/Documents/Chegging $ ./main Enter your password: kfm123!b Strong password shubh@ACER-NITR

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
Programming Problem 1 - File Name: pass.cpp (5 pts.)        Description: You were hired by...
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
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