Create a program that reads in two strings separated by a whitespace, which are two valid email addresses. Your program should print True if both addresses map to the same email address and False otherwise. According to email:
-addresses are not case sensitive
dots don't matter,
-and any '+' before the '@' and all characters after the '+' and before the '@' are ignored
in C++ please
// do comment if any problem arises
//code
//answer has been highlighted
#include <iostream>
#include <cstring>
using namespace std;
// this function converts given string to lowercase
void lower(string &str)
{
for (int i = 0; i < str.size(); i++)
str[i] = tolower(str[i]);
}
// this function cleans email addresses
void clean(string &str)
{
// convert to lowercase
lower(str);
// characters after + and @ are ignored
bool flag = false;
string temp = "";
for (int i = 0; i < str.size(); i++)
{
if (str[i] == '+')
flag = true;
if (str[i] == '@')
flag = false;
if (!flag)
temp += str[i];
}
str = temp;
}
int main(int argc, char const *argv[])
{
string email1, email2;
// read 2 strings
cin >> email1 >> email2;
// clean both addresses
clean(email1);
clean(email2);
// print true if both are sam
if (email1 == email2)
cout << "True\n";
else
cout << "False\n";
return 0;
}
Output:

Create a program that reads in two strings separated by a whitespace, which are two valid...
In python please. Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings from words that have a frequency equal to freq in a case insensitive manner. Your specific task is to write a function wordsOfFreqency(words, freq), which will return a list of strings (in the order in which they appear in the original list) that have a frequency same as the function parameter freq. The parameter words to the function...
C++ There are to be two console inputs to the program, as explained below. For each input, there is to be a default value, so that the user can simply press ENTER to accept any default. (That means that string will be the best choice of data type for the console input for each option.) The two console inputs are the names of the input and output files. The default filenames are to be fileContainingEmails.txt for the input file, and...
C++ question Input Format You are given two strings, a and b, separated by a new line. Each string will consist of lower case Latin characters ('a'-'z'). Output Format In the first line print two space-separated integers, representing the length of a and b respectively. In the second line print the string produced by concatenating a and b (a+b). In the third line print two strings separated by a space, a' and b'. a' and b' are the same as...
Prompt the user to enter two character strings. The program will then create a new string which has the string that appears second, alphabetically, appended to the end of the string that shows up first alphabetically. Use a dash (-') to separate the two strings. You must implement the function string appendStrings(string, string), where the return value is the combined string. Display the newly created string. Your program must be able to handle both uppercase and lowercase characters. You are...
Write a program that uses String method regionMatches to compare two strings input by the user. The program should prompt the user to enter two strings, the starting index in the first string, the starting index in the second string, and the number of characters to be compared. The program should print whether or not the strings are equal, (Ignore the case of the characters during comparison.) 四SAMPLE RUN #1: java StringCompare Highlight: None D Show Highlighted Only Interactive Session...
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...
Create a C project named login_l06t1. Write and test a function strnclean that takes two strings as parameters, target and source. Using the ctype library, copy only the alphabetic characters from source to target, and make the characters lower case. Ex: source: David Brown! target: davidbrown Prototype: void strnclean(char *target, const char *source); How do i do this using the C type library below! int isalnum(int c) Returns non-zero (true) if c is an alphanumeric character, zero otherwise. int isalpha(int...
Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences...
Note: Please test your output on the console and also avoid the
functions below.
We were unable to transcribe this image6. Write a function which combines two strings which are passed as 7. The trimLeft) method removes whitespace from the left end of a 8. Write a function which removes whitespace from both ends of the parameters. Mix one character from each string and return the concatenated result. function('ABC','Defg) return ADBeCfg string. Whitespace in this context is all the whitespace...
In this lab you will write a spell check program. The program has two input files: one is the dictionary (a list of valid words) and the other is the document to be spellchecked. The program will read in the words for the dictionary, then will read the document and check whether each word is found in the dictionary. If not, the user will be prompted to leave the word as is or type in a replacement word and add...