Can I please get some assistance on this?
Answer:
As multiple questions are there, answering first question as per guidelines:
Here is the code:
#include <iostream>
using namespace std;
int main()
{
string password;
cout<<"Please enter a password. It must be at least 8
characters long and contain at least 2 alpha characters, at least
one upper case and one lower case, at least 1 numbers, and at least
1 special character such as #, @ or $. Note that blank spaces are
not permitted."<<endl;
char try_again = 'y';
while(try_again!='n')
{
cout<<"Enter password: ";
getline(cin, password);
int alpha_count = 0;
int upper_count = 0;
int lower_count = 0;
int numbers_count = 0;
int special_count = 0;
int blanks = 0;
for(int i=0; i<password.length(); i++)
{
if(password[i]>='a' && password[i]<='z')
{
alpha_count++;
lower_count++;
}
else if(password[i]>='A' && password[i]<='Z')
{
alpha_count++;
upper_count++;
}
else if(password[i]>='0' && password[i]<='9')
{
numbers_count++;
}
else if(password[i]==' ')
{
blanks++;
}
else
{
special_count++;
}
}
if(password.length()<8 || alpha_count<2 || lower_count<1
|| upper_count<1 || numbers_count<1 || special_count<1 ||
blanks>0)
{
cout<<"Invalid password: "<<endl;
if(password.length()<8)
cout<<">>> At least 8 characters"<<endl;
if(alpha_count<2)
cout<<">>> At least 2 alpha
characters"<<endl;
if(lower_count<1)
cout<<">>> At least one lower
case"<<endl;
if(upper_count<1)
cout<<">>> At least one upper
case"<<endl;
if(numbers_count<1)
cout<<">>> At least one number"<<endl;
if(special_count<1)
cout<<">>> At least one special
character"<<endl;
if(blanks>0)
cout<<">>> Blank spaces are not
permitted"<<endl;
}
else
{
cout<<"Password accepted!"<<endl;
}
cout<<"Try again?";
cin>>try_again;
cin.ignore(100, '\n');
cout<<endl;
}
return 0;
}
Output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
Can I please get some assistance on this? 1. Write a program to test the correctness...
Problem with C++ program. Visual Studio say when I try to debug "Run-Time Check Failure #2 - Stack around the variable 'string4b' was corrupted. I need some help because if the arrays for string4a and string4b have different sizes. Also if I put different sizes in string3a and string4b it will say that those arrays for 3a and 3b are corrupted. But for the assigment I need to put arrays of different sizes so that they can do their work...
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
C
program
take values to 9 and the second can take values to 12 if (x > 2^3) printf("d", x); Int s-e; 21. LOST) Write a statement that declare an array of doubles with two indices, such that the first index can 22 (LOL) The following code will print out: 23. (L02.) The following code will print out: PART 2 Fill in the banks questions 3 marts x + 5; else x -- 2; char "stri - "abcd"; char str2[]...
SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL
CODE
PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT
NEEDED!!!
mystring.h:
//File: mystring1.h
// ================
// Interface file for user-defined String class.
#ifndef _MYSTRING_H
#define _MYSTRING_H
#include<iostream>
#include <cstring> // for strlen(), etc.
using namespace std;
#define MAX_STR_LENGTH 200
class String {
public:
String();
String(const char s[]); // a conversion constructor
void append(const String &str);
// Relational operators
bool operator ==(const String &str) const;
bool operator !=(const String &str) const;
bool operator >(const...
Note that the main function that I have provided does use <string.h> as it constructs test strings to pass to your functions. However, your solutions for the 5 functions below may not use any of the built-in C string functions from the <string.h> library. Write a function called strcmp373. This function is passed two parameters, both of which are C strings. You should use array syntax when writing this function; that is, you may use [ ], but not *...
1. Write a C++ program called Password that handles encrypting a
password.
2. The program must perform encryption as follows:
a. main method
i. Ask the user for a password.
ii. Sends the password to a boolean function called
isValidPassword to check validity.
1. Returns true if password is at least 8 characters long
2. Returns false if it is not at least 8 characters long
iii. If isValidPassword functions returns false
1. Print the following error message “The password...
From the Tony Gaddis text, the chapter on C-String and Class String: String Length: Write a Function that passes in a C-String and using a pointer determine the number of chars in the string. Data: “This is a test string for string length” Prt String Backwards: Write a Function that passes in a C-String and prints the string backwards. Data: “This is a test string for string backwards” replaceSubstring: Write a Function that accepts three C-Strings – str1,...
Write a C++ program that repeatedly reads lines until an EOF is encountered. As each line is read, the program strips out all characters that are not upper or lower case letters or spaces, and then outputs the line. Thus, the program acts as a filter and issues no prompt. There are many ways this program could be written, but to receive full credit, you must observe the following: Place your code in a file called filterChars.cpp. The program should...
Objectives: Use strings and string library functions. Write a program that asks the user to enter a string and output the string in all uppercase letters. The program should then display the number of white space characters in the string. You program should run continuously until the user enters an empty string. The program must use the following two functions: A function called count_spaces that counts the number of white spaces inside a string. int count_space(char str[]); which tell you...
1. Write a C++ program to output a framed greeting. The program will produce five lines of output. The first line begins the frame. It is a sequence of * characters as long as the person's name, plus some characters to match the salutation ("Hello, "), plus a space and an * at each end. The line after that will be an appropriate number of spaces with an * at each end. The third line is an *, a space,...