Question

In: Computer Science

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

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. The password should be 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 then verifies that it meets the stated criteria. If it doesn't, the program should display a message telling the user why.

Solutions

Expert Solution

C++ Program:

#include <iostream>

using namespace std;

//Declaring constants
const int SIZE = 80;
const int MIN = 6;


//Function Prototype
bool isValid(char pwd[]);


//Main function
int main()
{
//Character array that stores password
char password[SIZE];

//Loop till user enters a valid password
while(true)
{
//Displaying password requirements
cout << "\n\n Password requirements: \n - The password should be at least 6 characters long \n - The password should contain at least one uppercase ";
cout << "\n - and one lowercase letter. \n - The password should have at least one digit. \n";

//Reading password
cout << "\n Enter a password: ";
cin >> password;

//Validating password
if(isValid(password))
{
//If valid password
cout << "\n The password is valid \n";
break;
}
else
{
//If invalid password
cout << "\n The password was invalid \n";
}
}

cout << "\n\n";
return 0;
}


//Function Definition
bool isValid(char *password)
{
int i, len;
bool hasLower=false, hasUpper=false, hasDigit=false, hasLength;

//Finding length
len = strlen(password);

//Finding length
if(len >= MIN)
{
//Set length to true
hasLength = true;

//Iterating over string
for(i=0; i<len; i++)
{
//Testing for upper
if(isupper(password[i]) && hasUpper == false)
{
hasUpper = true;
}

//Testing for lower
if(islower(password[i]) && hasLower == false)
{
hasLower = true;
}

//Testing for digit
if(isdigit(password[i]) && hasDigit == false)
{
hasDigit = true;
}
}
}
else
{
cout << "\nPassword is not of minimum six characters long...\n";
//If length is not sufficient
return false;
}

//Checking one by one
if(hasDigit==false)
{
cout << "\nPassword doesn't contain digit....\n";
}
if(hasLower==false)
{
cout << "\nPassword doesn't contain lowercase letter....\n";
}
if(hasUpper==false)
{
cout << "\nPassword doesn't contain uppercase letter....\n";
}

//Return status
return (hasDigit && hasLower && hasUpper);
}
___________________________________________________________________________________________

Sample Run:


Related Solutions

Imagine you are developing a software package that requires users to enter their own passwords. Your...
Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that user’s passwords meet the following criteria: 1. The password should be at least six characters long. 2. The password should contain at least one uppercase and at least one lowercase letter. 3. The password should have at least one digit. Write a program that asks for a password and then verifies that it meets the stated criteria. If it doesn’t, the...
You are developing a software package for an online shopping site that requires users to enter...
You are developing a software package for an online shopping site 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. ● The password should contain at least one uppercase and at least one lowercase letter. ● The password should have at least one digit. Write a method that verifies that a password meets the stated criteria. Use this method in a...
Imagine you are developing a software package for an online shopping site that requires users to...
Imagine you are developing a software package for an online shopping site 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. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a class that verifies that a password meets the stated criteria. Demonstrate the class in a program that...
in your own words , How would you select a methodology for developing a software system?...
in your own words , How would you select a methodology for developing a software system? What are the criteria? For example, among Waterfall, Parallel, Rapid Application, or Agile development methodologies which one would you choose for your development project.
Early in 2021, the Excalibur Company began developing a new software package to be marketed. The...
Early in 2021, the Excalibur Company began developing a new software package to be marketed. The project was completed in December 2021 at a cost of $102 million. Of this amount, $68 million was spent before technological feasibility was established. Excalibur expects a useful life of five years for the new product with total revenues of $170 million. During 2022, revenue of $51 million was recognized. Required: 1. Prepare a journal entry to record the 2021 development costs. 2. Calculate...
[JAVA] You will write a program to validate passwords for users, making sure they meet the...
[JAVA] You will write a program to validate passwords for users, making sure they meet the following criteria: Rules: Passwords must be at least 8 characters long Passwords can only contain alpha numeric characters (no spaces or special characters) Passwords must contain at least 1 uppercase character Passwords must contain at least 1 lowercase character Passwords must contain at least 1 numeric character (0-9) Passwords cannot contain the word “password” A password that does not meet all of these rules...
exercise 5.2 Develop Your Own Commercial Imagine that you are your own “product.” You have to...
exercise 5.2 Develop Your Own Commercial Imagine that you are your own “product.” You have to sell yourself and your potential contributions to a potential employer or buyer. What would you sell? For example, what are some of the strengths you bring to the table? (Hint: Review the section in this chapter on seeing yourself as a “brand.”) On a separate sheet of paper, spend 5–10 minutes free writing and brainstorming about you as a commercial. Next, what action or...
Instructions: You must use Excel or a similar statistical software package, such as SPSS, for your...
Instructions: You must use Excel or a similar statistical software package, such as SPSS, for your assignment. Tasks: 1.Select thirty stocks (at least 3 different industries) that are listed on the Toronto Stock Exchange. 2.Track each stock’s closing price at the end of the trading day. These closing prices will appear on the Internet. Collect the stock closing price data from January 2017 to December 2019. 4. For each stock, use your data to calculate and interpret: (show calculations) a)the...
Imagine you are a time traveller and you enter a small medieval village and find your...
Imagine you are a time traveller and you enter a small medieval village and find your way to the only inn. The innkeeper rents rooms for $10 a week, which you pay, as that is the exact amount of money you brought. The innkeeper promptly goes across the street and buys a new pair of shoes (which were just being finished) from the cobbler for $10. Later the same day, the cobbler purchases a new bridle and a set of...
Imagine that you are starting your own company in your hyper-competitive industry: You
Imagine that you are starting your own company in your hyper-competitive industry: You are putting your life savings, your professional contacts, and your innovative ideas on the line. As you begin to hire a sales force, you consider binding new employees to noncompete agreements. Outline the ideal terms of your employees’ noncompetes. What is its duration? What is its geographical radius? Are these terms appropriate for your industry? When you are done, pass your proposed terms to classmates and discuss...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT