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
  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

  • C++ (1) Write a program to prompt the user for an input and output file name....

    C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...

  • 12 pts Please upload.cpp file only before the time up. The code must contain your name...

    12 pts Please upload.cpp file only before the time up. The code must contain your name and has proper format. Write a program that prompts a user to enter a line of text (including whitespace). Please use string object NOT e-string, a string library can be included. 1. Convert the input into uppercase and output the string to the screen. 2. Get the first and the last characters then appends the line with "I Love C++" and output the string...

  • C++ developing involves ut from a file a person's first name, last name, phone number and...

    C++ developing involves ut from a file a person's first name, last name, phone number and birth a menu driven database application. You need to 4) This program accept as input ogram will be menu driven with the following options: 1) Find a person's information 2) Add a person to the database 3) Edit a person's information 4) Display all records to the screen 5) Quit Option 1 allows the user to enter a name after which you will search...

  • IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...

    IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program. Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well...

  • ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of...

    ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of a file. The program encoded sentences in the file and writes the encoded sentences to the output file. Enter the file name: messages.txt Output: encoded words are written to file: messages.txt.swt The program reads the content of the file and encodes a sentence by switching every alphabetical letter (lower case or upper case) with alphabetical position i, with the letter with alphabetical position 25...

  • Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin....

    Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin.” The rules used by Pig Latin are as follows: • If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay". • If it begins with a consonant, then we take all consonants before...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • please help me out and input values please .. main cpp.. please follow intructions exactly witj...

    please help me out and input values please .. main cpp.. please follow intructions exactly witj clarity please CSE 110-Intro to Computer Programming Project #3 Requirements-String Class Functions and Test Case Documentation Using the String Class, design and develop a multi-file password validation program and Test case Document (10% of grade) that requests a password, and validates it based on the following criteria. The password must be at least 8 characters long, contain at least one number, and at least...

  • C++ programming: One line per input/output variable with the exact variable name followed by a description...

    C++ programming: One line per input/output variable with the exact variable name followed by a description 1. [8 points] Write a program that reads data from the file data.in. The file consists of an unknown number of lines each of which contains the unit price and the quantity of an item. For example, if the file data.in contained the following data: 16.00 24 7.47 13 2.10 15 12.47 18 Your program should output the following to your screen Unit Price...

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