Using c++, OOP class solve the problem Your next C++ program is to provide valid
ID: 3754709 • Letter: U
Question
Using c++, OOP class solve the problem
Your next C++ program is to provide validation for the selection of new passwords. For a password to be allowed it must follow these rules: It must contain at least one letter It must contain at least one digit . e . It must be at least 8 characters long It must not be a password in the "easy-to-guess" list It must not be a password that has already been selected twice previously The passwords in the "easy-to-guess" list will be provided in the file "easy.txt" with one password per line. You must store the easy-to-guess passwords using an array-based implementation of the ADT bag. The passwords that have been used once should be stored in another bag, with those being used twice in yet another bag. You may assume that no bag will ever contain more than 100 passwords. Prompt the user for a potential password, then display either the message "ACCEPT" or "REJECT TOO EASY" or "REJECT-TOO COMMON". Continue until the user enters "quit". The data file (easy.txt), class files (ArrayBag.h, ArrayBag.cpp, Baglnterface.h), and sample program (main.cpp) can be copied from the /home/gunnett@findlay.edu/BAG directory. Your program should follow the Documentation Guidelines handout given in class. Prepare a script session on Chip that will include your source code (use "cat"), the compiling of your program, and one execution using the following input data: Secret99 Footbal19 topten99 topten9 topten88 12345678 topten88 password88 mytest8 yoursbad topten88 quitExplanation / Answer
#include <iostream>
#include <stdio.h>
#include <string.h>
#include<fstream>
using namespace std;
bool checkupper (char *);
bool checklower (char *);
bool checkdigit (char *);
int main()
{
char password [20];
int length;
ifstream fin;
cout << "Please enter a password that is 8 - 20 characters long" << endl;
cout << "The password should contain at least one uppercase" << endl;
cout << "and one lowercase letter, as well as one digit." << endl;
cout << ">: ";
cin.get(password, 20);
cout << endl;
fin.open("easy.txt",ios::in);
while(!fin.eof){
if(fin.get(password))
cout<<"Reject easy to guess";
}
bool correct = checkupper(password);
if (correct == false)
cout << "Your password must contain one uppercase letter! ";
else if (correct == true)
correct = checklower(password);
if (correct == false)
cout << "Your password must contain at least one lowercase letter!";
else if (correct == true)
correct = checkdigit(password);
if(correct == false)
cout << "Your password must contain at least one digit!";
else if (correct == true)
cout << "Your password has been saved successfully";
system ("pause");
return 0;
}
bool checkupper (char* password)
{
for (int count = 0; count <20; count++)
{
if (!isupper(password[count]))
return false;
if(isupper(password[count]))
break;
}
}
bool checklower (char* password)
{
for (int count = 0; count <20; count++)
{
if (!islower(password[count]))
return false;
if(islower(password[count]))
break;
}
}
bool checkdigit (char* password)
{
for (int count = 0; count <20; count++)
{
if (!isdigit(password[count]))
return false;
if(isdigit(password[count]))
break;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.