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
|
#include <iomanip>
#include <iostream>
using namespace std;
char ch, array1, array2, array3, array4, array5, array6, array7;
int alphacount = 0, numcount = 0, tmpnum = 0, tmpLet = 0, tstA, tstB, tstC, tstD, tstE, tstF, tstG, input = 7, totalnum = 0, totallet = 0;
int isDigit(char);
int isUpper(char);
char convToUpper(char);
int main()
{char ui[7];
cout << "Enter user id in format ABC1234: " << endl ;
for (int i = 0; i <= input; i++)
{ui[7] = cin.get();
while (ui[0] != '!')
{
while (ui[0] != 10)
{
tstA = isDigit(ui[i]);
tstB = isUpper(ui[i]);
if (tstA == 1 )
{
tmpnum++;
}
else if (tstB == 1 )
{
tmpLet++;
}
else
{
ui[i] == convToUpper(ui[i]);
tmpLet++;
}
if (tmpLet == 4 && tmpnum == 3)
{
cout << ui << "Valid Id" << endl;
totallet += 3;
totalnum += 4;
}
else if (tmpLet !=4 && tmpnum != 3)
{
cout << ui << " Invalid id" << endl;
}
cout << "Enter another customer id in the format AAA1234 " << endl;
for(int i = 0; i <= input; i++)
{
ui[i] = cin.get();
tmpLet == 0;
tmpnum == 0;
}
}
}
cout << "Total number of characters: " <<setw(8) << totallet + totalnum;
cout << endl << endl << "Alphabetic: " << setw(24) << totallet << endl;
cout << "Numerical: " << setw(25) << totalnum;
return 0;
}
}
char convToUpper(char d)
{
if(d >= 97 && d <= 122)
{return ( d - 32);
}
else
return d;
}
int isUpper(char x)
{
if( x >= 65 && x <= 90)
return 1;
else
return 0;
}
int isDigit(char x )
{
if( x >= 48 && x <= 57)
return 1;
else
return 0;
}
|