#include <iostream.h ><br>#include <iomanip.h ><br>#include <string.h ><br>//#include <ctype><br>#include <ctype.h><br>#include <stdlib.h><br>//using namespace std;<br>float calcAverage(float[], float);<br>class Password // class declaration<br>{<br>public:<br>Password() { bRetVal = 0;} <br>Password(char* szPassPhase){<br>length = strlen(szPassPhase);<br>szPassword = new char[length+1];<br>strcpy(szPassword , szPassPhase );<br>}<br>int check(void);<br>void setPassword(char*);<br>private:<br>int HasUpperCase(void); //check for password<br>int HasLowercase(void);<br>int HasDigit(void);<br>char* szPassword;<br>int length;<br>int bRetVal;<br>};<br><br>//implementation<br><br>void Password::setPassword(char* string) {<br>strcpy(szPassword,string);<br>cout << szPassword << endl;<br>}<br><br>int Password :: check(){<br><br>while(bRetVal != 0){<br>if( (HasLowercase()) &&<br>(HasUpperCase()) &&<br>(HasDigit()) &&<br>(length >= 6))<br><br>cout<<"Your password is correct. Please process "<<endl;<br>break;<br>}<br>if(!bRetVal) {<br>cout<< "Your password is incorrect. exit and try again. "<<endl<br> << "Your password should be at least six characters long, "<<endl<br> << "and the password should contain at least one uppercase and at least one lower case letter. "<<endl<br> << "An example of the password is B12c34 "<<endl;<br>exit(0);<br>}<br> return bRetVal;<br><br>}<br><br>int Password::HasLowercase(){<br> bRetVal =0;<br> for(int x=0;x < length; x++)<br>if(islower((int)szPassword[x])) //return a non-zero value if true<br>{<br>bRetVal = 1;<br>break;<br>}<br> return bRetVal;<br>}<br><br>int Password::HasUpperCase() {<br>bRetVal = 0;<br>for(int x=0; x<length;x++)//returns a no-zero<br>if(isupper((int)szPassword[x])){<br>bRetVal = 1;<br>break;<br>}<br>return bRetVal;<br>}<br><br>int Password::HasDigit() {<br>bRetVal =0;<br>for (int x=0;x<=length;x++)<br>if(isdigit((int)szPassword[x])) {<br>bRetVal = 1;<br>break;<br>}<br>return bRetVal;<br>}<br><br>struct Student<br>{<br> char name[20];<br> char idnum[10];<br> float testGrade[];<br>};<br>void populate(Student *);<br>// calcAverage(Student *);<br>//void display (Student *);<br><br><br><br><br>int main()<br>{<br>char* string ="B12c34 ";<br>Password a = Password(string) ;<br>cout<<"Type in your password: ";<br>cin.getline(string, 10);<br>cout<<"the password is: " <<string<< endl;<br>a.check();<br>a.setPassword(string);<br><br>Student stud ;<br><br>int i=0 , ch=0;<br>float testGrade[]= {0.00};<br>float average, num=0.00;<br>cout<< "\nEnter a grade or -1 to terminate the program ";<br>cin>>testGrade<i>;<br>while(stud.testGrade<i> >= 0.00 && i < ch)<br>{<br> i++;<br> cout<<"Enter a grade or -1 to terminate data entry: ";<br> cin >> stud.testGrade<i>;<br>}<br>ch = i;<br><br>if(ch >0);<br>{<br> average = calcAverage(testGrade, num ) ;<br> cout <<"The average of the grades is "<< average<<endl;<br> // display(average);<br>}<br>return 0;<br>}<br><br>void populate(Student *record)<br>{<br> cout<< "\nEnter student information: ";<br> cout<< "\nStudent's name ";<br> cin.getline(record->name, 10);<br> cout<< "\nEnter the student's id numbner: ";<br> cin>>record->idnum;<br> cout<< "\nEnter The test grade ";<br> cin>>record->testGrade[10];<br><br> return;<br>}<br><br> float calcAverage(float testGrade[], float )<br>{<br> int ch, i=0;<br><br> float total =0.00, average;<br> cout<<"List all the grades for this sutdent: ";<br> cin>>testGrade<i>;<br> for(i=0; i< ch; i++)<br> {<br> cout<< "List all the grades of this student: ";<br> cin>>testGrade<i>;<br><br> //calculate the sum of the grades<br> total = total + testGrade<i>;<br> }<br> average = total /ch ;<br> return average; //calculate and return average<br><br>}<br><br><br><br><br>