1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
RSB [31]
4 years ago
4

Password Verifier 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 contain 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.

Computers and Technology
1 answer:
madreJ [45]4 years ago
4 0

Answer:

Here is the C++ program:

#include <iostream>  //to use input output functions

using namespace std;  //to identify objects like cin cout

bool verifyLength(string password);  // to verify length of password

bool verifyUpper(string password);  //to verify if  password contains uppercase letters

bool verifyLower(string password);  //to verify if  password has lowercase letters

bool verifyDigit(string password);  // to verify if password contains digits

int main() {   //start of main() function

   string password = " ";  //to hold password string input by user

  while(true)     {  //loop that verifies the password. The loop keeps prompting user to enter a valid password telling what criteria is to be met to verify password.

       cout << "\nPlease enter your password: ";  // prompts user to enter a password

       getline(cin, password);  //reads and gets password from user

           if (verifyLength(password) == false)  // calls verifyLength to check length criteria for password. Checks if length of password is less than 6

             { cout << "The password should be at least six characters long.\n";}                                        

else if (verifyUpper(password) == false)   { // calls verifyUpper to check criteria for password letters to be in uppercase. Checks if password does not have an uppercase letter

   cout << "The password should contain at least one uppercase letter.\n";  }  

         else if (verifyLower(password) == false) {  // calls verifyLower to check criteria for password letters to be in lowercase.  Checks if password does not contain a lowercase letter

           cout << "The password should contain at least one lowercase letter.\n";   }

          else if (verifyDigit(password) == false)  {   // calls verifyDigit to check digit criteria for password. Checks if password does not contain a digit

           cout << "The password should have at least one digit.\n";    }  

        else {  //if password meets the criteria

          cout << "Password verified!\n";  

         break;   }     } }   //breaks the loop                

Explanation:

Here are the method that are called to verify the stated criteria:  

bool verifyLength(string password)  {  // this method takes input password as parameter to verify the length criteria and returns true of false accordingly

   bool length = false;   // the bool type variable length is initially set to false

   if(password.length() >= 6)  //if the length of the password that is obtained by using length() function is greater than or equals to 6 then it means it meets valid password length criteria

   length = true;   //set length to true when above if statement is true

   else  //if length of password is less than 6

   length = false;   //set length to false if length of password  is less than 6

   return length;  }   //return the state of length

bool verifyUpper(string password)  {  // this method takes input password as parameter to verify the uppercase criteria and returns true of false accordingly

   bool upper = false;   // the bool type variable upper is initially set to false

   for (int i = 0; i < password.length(); i++)     { //the loop iterates through the letter of password string until the length of the string is reached

       if (isupper(password[i]))         {  //it checks if any letter of the password is in uppercase using the isupper() method

           upper = true;       }        }   //set upper to true when above if condition is true

   return upper;  }  //returns the state of upper

bool verifyLower(string password)  { // this method takes input password as parameter to verify the lowercase criteria and returns true of false accordingly

   bool lower = false;  // the bool type variable lower is initially set to false

   for (int i = 0; i < password.length(); i++)     { //the loop iterates through the letter of password string until the length of the string is reached

       if (islower(password[i]))         {  //it checks if any letter of the password is in lowercase using the islower() method

           lower = true;         }     }   //set lower to true when above if condition is true

   return lower;  } //returns the state of lower accordingly

bool verifyDigit(string password)  {  // this method takes input password as parameter to verify the digit criteria and returns true of false accordingly

   bool digit = false;   // the bool type variable digit is initially set to false

   for (int i = 0; i < password.length(); i++)     {  //the loop iterates through each letter of password string until the length of the string is reached

       if (isdigit(password[i]))         {  //it checks if any letter of the password is a digit using the isdigit() method

           digit = true;         }     } //set digit to true when above if condition is true

    return digit;  }    //returns the state of digit accordingly                                  

The output of program is attached.

You might be interested in
Anyone have gmetrix week 2 quiz?
Zielflug [23.3K]

Answer:

Yes

Explanation:

6 0
3 years ago
Read 2 more answers
We want to implement a data link control protocol on a channel that has limited bandwidth and high error rate. On the other hand
Korolek [52]

Answer:

Selective Repeat protocols

Explanation:

It is better to make use of the selective repeat protocol here. From what we have here, there is a high error rate on this channel.

If we had implemented Go back N protocol, the whole N packets would be retransmitted. Much bandwidth would be needed here.

But we are told that bandwidth is limited. So if packet get lost when we implement selective protocol, we would only need less bandwidth since we would retransmit only this packet.

6 0
3 years ago
Just answer the 2 questions. THX
pogonyaev

Answer:

A then D

Explanation:

3 0
3 years ago
Which 10 gigabit standard uses mmf cabling for distances up to 300 meters and is often used for sonet campus networks?
WITCHER [35]

I guess the correct answer is 10GBase-SW

10GBASЕ-SW mеdia typеs arе dеsignеd fοr usе οvеr shοrt wavеlеngth (850 nm) multimοdе fibеr (MMF). Thе dеsign gοal οf thеsе mеdia typеs is frοm 2 mеtеrs tο 300 mеtеrs οf fibеr distancе, dеpеnding οn thе typе and quality οf thе multimοdе fibеr. Lοngеr distancеs arе pοssiblе dеpеnding οn thе qualitiеs οf thе fibеr οptic cablе usеd. Thе 10GBASЕ-SW mеdia typе is dеsignеd tο cοnnеct tο SΟNЕT еquipmеnt, which is typically usеd tο prοvidе lοng distancе data cοmmunicatiοns.

5 0
3 years ago
Explain the steps users can take to maintain an operating system
Mars2501 [29]

First is it to always clean out all the junk that is left behind by the operating system and the browsers. You can easily do this using the Disk Cleanup utility included on the windows systems. You can clean up the registry. However, you should be very careful with the registry. Any wrong move might mess up everything


Search and destroy viruses and malware on your PC by installing an anti-virus security program and setting up an automated maintenance schedule.


Defragment main and partitioned drives to keep your computer running smoothly.


Uninstall software programs and personal files like pictures, movies and music that are no longer in use to free up more space. The more the space, the faster the PC will go. You can also run the msconfig command in the RUN command prompt to uncheck start up programs that you do not use

4 0
4 years ago
Other questions:
  • Someone may choose to own a car instead of leasing because:
    14·2 answers
  • COMPUTER ORGANIZATION &amp; ARCHITECTURE I<br>please help need the correct answers to all
    6·1 answer
  • Can anyone help me<br> I will make you a brainalist
    13·1 answer
  • You create a formula in A8 that adds up the numbers listed in A1 through A7. You copy the formula and paste it into C8. What hap
    9·1 answer
  • Which act will the person be punished by trying to obtain personal information employees illegally?
    11·1 answer
  • How to find out what version of windows i have?
    13·1 answer
  • What device is used to transmit what is effectively a type of Morse code between stations?
    11·1 answer
  • The InfoBar is located below the ribbon and on top of a message. It is used for which purposes? Check all that apply. showing th
    9·2 answers
  • What is the purpose of exploring data?
    6·2 answers
  • Which is the best description of the difference between bound and unbound forms?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!