Hello fellas,
Last thing you want to do is probably help me with some HW, but just in case there are some generous souls in an advising mood...
Here's what I got, I have to create a program that asks the user to input a password, and it has to meet 3 criteria;
1. Be at least six char. long.
2. Must contain one capital or one lowercase char.
3. Contain at least one digit.
Here's where I need help...
Do I go about this in a "bool" fashion and check the password after the input and see if each of the criteria are met and set that as "true" and if one isn't set it as "false" and then using "if" functions report back to the user the error?
or
Is it possible to just "if" function the whole part where the user inputs an unusable password...
Also, have no idea how to check for capital letters or digits in the password...I guess thats my number 1 problem.
Here's what I have so far though,
Any help is appreciated, thanks guys!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
//
// This program will create a password for the user with 3 criteria in mind.
// HW_9
//
// Created by Vlad Tumasyan on 4/26/14.
// Copyright (c) 2014 Vlad Tumasyan. All rights reserved.
//
#include <iostream>
#include <cctype>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
char pass [6];
//Tells user the criteria for the new password
cout<<"Please enter a new password \n";
cout<<"Please remember to include the following \n";
cout<<"1. Your password must be at least six (6) characters long. \n";
cout<<"2. Your password must contain at least one uppercase or one lowercase letter. \n";
cout<<"3. Your password must contain at least one (1) digit. \n \n \n";
//Asks user to input a possible password
cout<<"Please enter a password with the previous criteria in mind...";
cin>>pass;
cout<<endl <<pass;
return 0;
}
|