Have the function CodelandUsernameValidation(str) take the str parameter being passed and determine if the string is a valid username according to the following rules:
1. The username is between 4 and 25 characters.
2. It must start with a letter.
3. It can only contain letters, numbers, and the underscore character.
4. It cannot end with an underscore character.
If the username is valid then your program should return the string true, otherwise return the string false.
#include <iostream>
#include <string>
using namespace std;
string CodelandUsernameValidation(string str) {
if(str.size()<4||str.size()>25)return "false";
if(int(str[0])<65||int(str[0])>122)return "false";
if(int(str[0])>90&&int(str[0])<97)return "false";
if(str[str.size()-1]=='_')return "false";
for(int i=1;i<str.size();i++){
if(int(str[i])<65||int(str[i])>122)if(str[i]!='_')if(int(str[i]<48&&int(str[i])>57))return "false";
if(int(str[i])>90&&int(str[i])<97)if(str[i]!='_')if(int(str[i]<48&&int(str[i])>57))return "false";
}
return "true";
}
int main(void) {
cout << CodelandUsernameValidation(coderbyteInternalStdinFunction(stdin));
return 0;
}