Keeping this code written as close to this as possible and only using these headers. How do I turn this in to a code that can read from 3 files of passwords then sort them into two files. One for valid passwords and the other for invalid passwords and then send a message to the user that says how many are valid and how many are invalid. Only using
std::ifstream fin;
fin.open("data.txt");
fin.close();
std::ofstream fout;
fout.open("data.txt");
fout.close();
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string password;
size_t size = 0;
int no_digits = 0;
bool correct_password = true;
do
{
correct_password = true;
cout << "Enter password: ";
cin >> password;
size = password.length();
// CHECK LENGTH
if( size < 8 )
{
cout << "Password must contain 8 or more characters\n";
correct_password = false;
}
// CHECK ALL ALPHANUMERIC
for(size_t i = 0; i < size; i++)
{
if ( !isalnum(password[i]))
{
cout << "Password contains non alphanumeric character\n";
correct_password = false;
}
}
// CHECK NUMBER OF DIGITS
for(size_t i = 0; i < size; i++)
{
if ( isdigit(password[i]))
{
no_digits++;
}
}
if (no_digits < 2)
{
cout << "Password contains less than 2 digits\n";
correct_password = false;
}
cout << "Password ";
if( correct_password)
cout << "is ";
else
cout << "is not ";
cout << "acceptable\n";
} while( correct_password == false);
return 0;
}
/*
* C++ Program
* valid - Invalid password sorting
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string password;
size_t size = 0;
int no_digits = 0;
bool correct_password = true;
ifstream fin;
fin.open("pass.txt");
ofstream fout1, fout2;
fout1.open("valid.txt");
fout2.open("inalid.txt");
int countValid = 0, countInvalid = 0;
while (!fin.eof())
{
correct_password = true;
/*
cout << "Enter password: ";
cin >> password;
*/
fin >> password;
size = password.length();
// CHECK LENGTH
if( size < 8 )
{
// cout << "Password must contain 8 or more characters\n";
correct_password = false;
}
// CHECK ALL ALPHANUMERIC
for(size_t i = 0; i < size; i++)
{
if (!isalnum(password[i]))
{
// cout << "Password contains non alphanumeric character\n";
correct_password = false;
}
}
// CHECK NUMBER OF DIGITS
for(size_t i = 0; i < size; i++)
{
if ( isdigit(password[i]))
{
no_digits++;
}
}
if (no_digits < 2)
{
// cout << "Password contains less than 2 digits\n";
correct_password = false;
}
/*
cout << "Password ";
if(correct_password)
cout << "is ";
else
cout << "is not ";
cout << "acceptable\n";
*/
if (correct_password)
{
fout1 << password << endl;
countValid++;
}
else
{
fout2 << password << endl;
countInvalid++;
}
}
cout << "Total passwords: " << countValid + countInvalid << endl;
cout << "Valid passwords: " << countValid << endl;
cout << "Invalid passwords: " << countInvalid << endl;
fin.close();
fout1.close();
fout2.close();
return 0;
}
/* Program ends here */

Pass file

Valid pass file

Invalid pass file

Note: The unwanted lines are commented in your code, please drop comments fro queries.
Keeping this code written as close to this as possible and only using these headers. How...
Can someone help me put the string removee the return to an outfile and fix?? prompt: CS 575 LabEx14: no e’s Let the user specify an input file and an output file (text files). Read the input file and write the output file; the output file should be the same as the input file, except that it has no e’s. For example, if the input file had the line. Streets meet in the deep. Then the output file would have...
C++ Can someone please help me with this problem- commenting each line of code so I can understand how to solve this problem using the C++ programming language? I really need help understanding how to create a file for the program to read. Do I create the file in Visual basic or create a text file? I have the code, just need to know how to create the file for it to read. #include<fstream> #include<iostream> using namespace std; int main()...
I'm just a beginner in programming,how to make this program more simple without using #include<iostream> and #include<redex> here is the question Terms to know: If-else statement,for..while..do while,loops,pointer,address,continue,return,break. Create a C++ program which contain a function to ask user to enter user ID and password. The passwordmust contain at least 6 alphanumeric characters, 1 of the symbols !.@,#,$,%,^,&,* and 1 capital letter.The maximum allowable password is 20. Save the information. Test the program by entering the User ID and password. The...
#include using namespace std; vector split_string(string); // Complete the findMedian function below. int findMedian(vector arr) { } int main() { ofstream fout(getenv("OUTPUT_PATH")); int n; cin >> n; cin.ignore(numeric_limits::max(), '\n'); string arr_temp_temp; getline(cin, arr_temp_temp); vector arr_temp = split_string(arr_temp_temp); vector arr(n); for (int i = 0; i < n; i++) { int arr_item = stoi(arr_temp[i]); arr[i] = arr_item; } int result = findMedian(arr); fout << result << "\n"; fout.close(); return 0; } vector split_string(string input_string) { string::iterator new_end = unique(input_string.begin(), input_string.end(), []...
Hi there! I need to fix the errors that this code is giving me and also I neet to make it look better. thank you! #include <iostream> #include <windows.h> #include <ctime> #include <cstdio> #include <fstream> // file stream #include <string> #include <cstring> using namespace std; const int N=10000; int *freq =new int [N]; int *duration=new int [N]; char const*filename="filename.txt"; int songLength(140); char MENU(); // SHOWS USER CHOICE void execute(const char command); void About(); void Save( int freq[],int duration[],int songLength); void...
Sometimes when I sit in restaurants waiting on food, I request the children’s menu to play the games. One of my favorites is the word puzzle in which you search for words hidden in a scramble of letters. I began to work out a solution to this game programmatically. That seemed a little simple, so I decided to have you solve the problem of a scramble of integers, finding the sub-row or sub-column which sums to another integer. You will...
Create a program via Java that has atleast 8 characters long, one upper case, and one lower case, and one digit. here is my code: public static void main(String[] args) { //variables defined String passwords; char password =0; //settings up password condition to false boolean passwordcondition= false; boolean size=false; boolean digit=false; boolean upper=false; boolean lower=false; //inputting a scanner into the system Scanner keyboard = new Scanner(System.in);...
The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #define MAX 1000 using namespace std; //Function to Add a new inventory item to the data into the array in memory void addItem(string desc[],string idNum[], float prices[], int qty[],int &num) { cout<<"Enter the names:"; cin>>desc[num]; cout<<"Enter the item number:"; cin>>idNum[num]; cout<<"Enter the price of item:"; cin>>prices[num]; cout<<"Enter the...
#include <iostream>
using namespace std;
int * newZeroArray(int size) {
//your code here
}
int main() {
int size = 10;
int * A = newZeroArray(size);
for(int i = 0; i < size; i++)
cout << A[i] << " ";
cout << endl;
}Write a function that takes a size, creates a new array of that size with all zeros, and returns the array. If the size is not a valid size for an array, do not return a valid...
Write an interactive program exam1 that loops Loop and asks the user at the end of the loop to continue or not Ask the user to enter an alphanumeric US phone number Read the line of text from the screen Check if the entered string is a valid phone number using isValid(Line) if it is valid number { call toNumeric(line) to convert it to digits print Line after conversion } bool isValid(char line[]) { //st must have 10 digits and...