Apr 6, 2015 at 6:32pm UTC
So if i don't have character and aphabet it suppose to add two number and send it to reason function but for some reason if i type 123 it won't print
less character alphabet Uppercase, lowercase, etc....
and i never get 15 for somreaons...
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
const string COMMA = "," ;
int validate(string passward);
string findReason(int code);
void display(string result);
int main()
{
int code, check = 0;
string passward, result;
bool validornot;
do {
cout << "Enter the Passward" << endl;
cin >> passward;
cout << passward << endl;
check = validate(passward);
code = validate(passward);
result = findReason(code);
display(result);
if (check == 15)
validornot = false ;
else
validornot = true ;
} while (validornot);
return 0;
}
int validate(string passward)
{
int alph = 0, low = 0, up = 0, digit = 0, cha = 0;
int number = 0;
char ch;
//got helped from a friend here
if (passward.length() < 6)
cha+=1;
for (int i = 0; i < passward.length(); i++)
{
ch = passward[i];
if (isalpha(ch))
alph++;
if (isdigit(ch))
digit++;
if (ch == tolower(ch))
low++;
if (ch == toupper(ch))
up++;
}
if (cha < 1)
number += 20;
// 1 3 5 9
else if (alph < 1)
number += 1;
//2 3 10 6
else if (digit < 1)
number += 2;
//4 5 6 12
else if (low < 1)
number += 3;
//8 9 10 12
else if (up < 1)
number += 4;
cout << number << endl;
return number;
}
string findReason(int code)
{
string validnot = "" , str;
str = "Not Valid Reasons:" ;
if (code == 15)
str = "YES VALID NUMBER!!!!!" ;
else if (code == 21 || code == 22 || code == 24 || code == 28 || code == 20)
str = str + " Less Character-" ;
else if (code == 1 || code == 3 || code == 10 || code == 6 || code == 21)
str += " Alphatbet-" ;
else if (code == 2 || code == 3 || code == 10 || code == 6 || code == 22)
str += " Digit-" ;
else if (code == 4 || code == 5 || code == 6 || code == 12 || code == 24)
str += " Lowcasae-" ;
else if (code == 8 || code == 9 || code == 10 || code == 12 || code == 28)
str += " Uppercasae" ;
validnot = str;
return validnot;
}
void display(string result)
{
cout << result << endl;
}
Last edited on Apr 6, 2015 at 6:34pm UTC
Apr 6, 2015 at 6:34pm UTC
Last edited on Apr 6, 2015 at 6:35pm UTC