Almost there 2ffat,<br>Pass word function is now working. Some little problem. "Enter the nmae and ID of the student" won't compute. Somehow, the cin.getline is not picking it up.<br>#include <iostream.h ><br>#include <string.h ><br>//#include <ctype><br>#include <ctype.h><br>#include <stdlib.h><br>//using namespace std;<br>float calcAverage(float[], int);<br>void display(float[], int, float);<br><br>class Password // class declaration<br>{<br> public:<br> Password(); //{ bRetVal = 0;}<br> Password(char* szPassPhase)<br>{<br> length = strlen(szPassPhase);<br> szPassword = new char[length+1];<br> strcpy(szPassword , szPassPhase );<br>}<br><br> int check(void);<br> void setPassword(char*);<br> <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>{<br> strcpy(szPassword,string); //<br> cout << szPassword << endl;<br>}<br><br>int Password :: check()<br>{<br><br> while(bRetVal != 0)<br> {<br> if(HasLowercase()&&HasUpperCase()&&HasDigit()&&length >= 6)<br><br><br> cout<<"Your password is correct. Please process "<<endl;<br><br> break;<br> }<br> if(!bRetVal)<br> {<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><br> return bRetVal;<br><br>}<br><br>int Password::HasLowercase()<br>{<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>{<br> bRetVal = 0;<br><br> for(int x=0; x<length;x++)//returns a no-zero<br> <br> if(isupper((int)szPassword[x]))<br> {<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[50];<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><br>a.setPassword(string);<br>a.check();<br><br><br><br>Student stud;<br><br>int i=0 , ch=0, num = 0;<br>float testGrade[50];<br>float average;<br><br>average=calcAverage(testGrade, ch);<br><br><br><br><br><br>}<br><br><br>float calcAverage(float testGrade[], int HowManyGrade )<br>{<br> int i=0,j, id;<br> int HowManyStud;<br> char student[20];<br> float total=0.00, average;<br> while(testGrade)<br> {<br><br> cout<<"How many student are you going to record ";<br> cin>>HowManyStud;<br><br> for(i =0; i <= HowManyStud; ++i)<br> {<br><br> cout<<"Enter the names and the IDs of the student: "<<endl;<br> cin.getline(student, 20) ;<br><br> cout<<"How many grade are you going to record for this student: ";<br> cin>>HowManyGrade;<br> for( j = 0; j < HowManyGrade ; ++j)<br> {<br> cout<<"Enter another grades for the students "<<endl;<br> cin>>testGrade[j];<br><br> }<br> }<br> }<br> total = total + testGrade[j];<br> average = total /HowManyGrade ; //calculate and return average<br> return average;<br><br><br>}<br><br>void display(float nums[], int numel, float av)<br>{<br> int i = 0;<br> cout<<"\nThe grades are: \n";<br> for (i=0; i<numel; i++)<br> {<br> if(nums<i> <(av) )<br> cout<<"*";<br> else<br> cout<<" ";<br> cout<<nums<i> <<endl;<br> }<br><br><br> return;<br> }<br><br><br><br>