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 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 program should display a message telling the user why.

Your implementation should use a Class Password with a private data string type to

store the password, class methods as needed such as constructors, and public

methods that should be used in the main function to check the password:

bool isLongEnough();

bool hasDigit();

bool hasUpperAndLowerCase();

Needs to be in c++ and I am using Microsoft Visual Studio 2019. Thanks!

Solutions

Expert Solution

#include <iostream>
#include <string.h>
#include <list>

using namespace std;

//class password
class Password
{
string pwd;
public:
  
//default constructor
Password()
{
pwd = "";
}
  
//parameterize constructor
Password(string pass)
{
pwd = pass;
}
  
//function to check the length of the password
bool isLongEnough()
{
int length;
length = pwd.size();
  
if(length<6)
return false;
else
return true;
}

//function to check if the password has a digit
bool hasDigit()
{
for(int i=0; i<pwd.size(); i++)
{
if(isdigit(pwd[i]))
return true;
}
return false;
}

//function to check if the password has upper case and lower case
bool hasUpperAndLowerCase()
{
int lowercase = 0, uppercase = 0;
  
for(int i=0; i<pwd.size(); i++)
{
if(isupper(pwd[i]))
uppercase++;
  
if(islower(pwd[i]))
lowercase++;
}
if(uppercase && lowercase)
return true;
return false;
}
};

int main()
{
//create object
Password password1("hHldfd#9");
Password password2("hHldfd");
  
//check the password
if(password1.isLongEnough() && password1.hasDigit() && password1.hasUpperAndLowerCase())
{
cout<<"Password format is correct.";
}
else
{
cout<<endl<<"Password format is not correct.";
}
  
if(password2.isLongEnough() && password2.hasDigit() && password2.hasUpperAndLowerCase())
{
cout<<endl<<"Password format is correct.";
}
else
{
cout<<endl<<"Password format is not correct.";
}
  
return 0;
}

OUTPUT:


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