×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Password verifier

Password verifier

Password verifier

(OP)
can some one help me finishing this problem.

#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#include <ctype.h>

class Password    // class declaration
{
  public:
Password();
Password(char);
check();
void setPassword(char);
  private:
HasUpperCase();   //check  for password
HasLowercase();
HasDigit();
char szPassword;
}

//implementation


Password::Password()

Password::Password(char szPassword)
{

  szPassword = szPasssPhase;
}

Password::check()
{
  while(bReturnValue != 0)
{
if((HasLowerCase()) &&
  (HasUpperCase())  &&
  (Hasdigit())      &&
  (szPassword.length() >=6))
cout<<"Your password is correct. Please process "<<endl;
}
  while (bReturnValue =0)
{
cout<< "Your password is incorrect.  exit and try again. "<<endl;
exit()
}
  return bReturnValue;

}
Password::HasLowerCase()
{
 int x;
 bRetVal =0;
 for(x=0;x<=(szPassword.lenght()-1); x++0
 {
if(islower((int)szPassword[x]))  //return a non-zero value if true
{
  bRetVal !=0;
  break;
}
 }

 return bRetVal;

 Password::HasUpperCase()
 {
bRetVal = 0;
int x;

for (x=0;; x<=(szPassword[x]))//returns a no-zero
  {
if(isupper((int)szPassword[x]))
{
(bRetval !=0)
break;
}

  {
  return bRetVal;
}

 Password::HasDigit()
 {
bRetVal =0;
int x;

for (x=0;x<=(szPasswordl.length()-1)
{
  if(isdigit((int)szPassword[x]))
  {
bRetVal !=0;
break;
  }
  return bRetVa;;
}
 int main()
 {
Password a, b, c , d;
cout<<"the password is: "
a.Password()
b.Password(string):
c.Check();
d.setPassword(string;
 }

I am stuck

RE: Password verifier

I've rewritten your code please check it if it solves your problem. But you had a lot of syntax errors.

#include <iostream >
#include <iomanip >
#include <string >
//#include <ctype>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

class Password    // class declaration
{
public:
Password() { bRetVal = 0;}
Password(char* szPassPhase){
length = strlen(szPassPhase);
szPassword = new char[length+1];
strcpy(szPassword , szPassPhase );
}
int check(void);
void setPassword(char*);
private:
int HasUpperCase(void);   //check  for password
int HasLowercase(void);
int HasDigit(void);
char* szPassword;
int length;
int bRetVal;
};

//implementation

void Password::setPassword(char* string) {
strcpy(szPassword,string);
cout << szPassword << endl;
}

int Password :: check(){

while(bRetVal != 0){
if( (HasLowercase())  &&
(HasUpperCase())  &&
(HasDigit())      &&
(length >= 6))
cout<<"Your password is correct. Please process "<<endl;
}
if(!bRetVal) {
cout<< "Your password is incorrect.  exit and try again. "<<endl;
exit(0);
}
  return bRetVal;

}

int Password::HasLowercase(){
 bRetVal =0;
 for(int x=0;x < length; x++)
if(islower((int)szPassword[x]))  //return a non-zero value if true
{
bRetVal = 1;
break;
}
 return bRetVal;
}

int Password::HasUpperCase() {
bRetVal = 0;
for(int x=0; x<length;x++)//returns a no-zero
if(isupper((int)szPassword[x])){
bRetVal = 1;
break;
}
return bRetVal;
}

int Password::HasDigit() {
bRetVal =0;
for (int x=0;x<=length;x++)
if(isdigit((int)szPassword[x]))  {
bRetVal = 1;
break;
}
return bRetVal;
}


int main() {
char* string = "h123";
Password a = Password(string) ;
cout<<"the password is: " << endl;
a.check();
a.setPassword(string);
return 0;
}


RE: Password verifier

(OP)
I got stuck in this program.  I need to be able to access the program after the password is correct.  Then I have to put in several student's name, student's id and their grades.  I have to calculate their average grade earned. (Each students have few differents grades.)

#include <iostream.h >
#include <iomanip.h >
#include <string.h >
//#include <ctype>
#include <ctype.h>
#include <stdlib.h>
//using namespace std;

class Password    // class declaration
{
public:
Password() { bRetVal = 0;}
Password(char* szPassPhase){
length = strlen(szPassPhase);
szPassword = new char[length+1];
strcpy(szPassword , szPassPhase );
}
int check(void);
void setPassword(char*);
private:
int HasUpperCase(void);   //check  for password
int HasLowercase(void);
int HasDigit(void);
char* szPassword;
int length;
int bRetVal;
};

//implementation

void Password::setPassword(char* string) {
strcpy(szPassword,string);
cout << szPassword << endl;
}

int Password :: check(){

while(bRetVal != 0){
if( (HasLowercase())  &&
(HasUpperCase())  &&
(HasDigit())      &&
(length >= 6))

cout<<"Your password is correct. Please process "<<endl;
break;
}
if(!bRetVal) {
cout<< "Your password is incorrect.  exit and try again. "<<endl
<< "Your password should be at least six characters long, "<<endl
<< "and the password should contain at least one uppercase and at least one lower case letter. "<<endl
<< "An example of the password is B12c34 "<<endl;
exit(0);
}
  return bRetVal;

}

int Password::HasLowercase(){
 bRetVal =0;
 for(int x=0;x < length; x++)
if(islower((int)szPassword[x]))  //return a non-zero value if true
{
bRetVal = 1;
break;
}
 return bRetVal;
}

int Password::HasUpperCase() {
bRetVal = 0;
for(int x=0; x<length;x++)//returns a no-zero
if(isupper((int)szPassword[x])){
bRetVal = 1;
break;
}
return bRetVal;
}

int Password::HasDigit() {
bRetVal =0;
for (int x=0;x<=length;x++)
if(isdigit((int)szPassword[x]))  {
bRetVal = 1;
break;
}
return bRetVal;
}

struct Student
{
  char name[20];
  int idnum[10];
  int testGrade[];
}
void populate(Student *);
void possesInfo(Student *);
void display (Student *);




int main() {
char* string =" ";
Password a = Password(string) ;
cout<<"Type in your password: ";
cin.getline(string, 10);
cout<<"the password is: " <<string<< endl;
a.check();
a.setPassword(string);
return 0;
}

void populate(Student *record)
{
  cout<< "\nenter student information: ";
  cout<< "\nStudent's name ";
  cin.getline(record->name, 10);
  cout<< "\nEnter the student's id unmber: ";
  cin>>record->idnum[10];
  cout<< "\nEnter The test grade ";
  cin>>record->testGrade[];

  return;
}

void prossesInfo(Student *record)
{
int count;
   float total, num, average;
cout << "Enter the name of the student: "
cin.getline((record->name, 10);

for ( count = 0; count < record->testGrade; count++)
{
count <<"Enter a grade of this student: ";




can you help?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close