Read a 2-character string from input into variable userString. Declare a Boolean variable containsLowercase and assign containsLowercase with true if userString contains a lowercase letter. Otherwise, assign containsLowercase with false. Ex: If the input is vM, then containsLowercase is assigned with true, so the output is: Valid string Ex: If the input is $%, then containsLowercase is assigned with false, so the output is: Invalid string Note: Use getline(cin, userString) to read the entire line from input into userString. #include #include #include using namespace std; int main() { string userString; /* Your code goes here */ if (containsLowercase) { cout << "Valid string" << endl; } else { cout << "Invalid string" << endl; } return 0; }
Read a 2-character string from input into variable userString. Declare a Boolean variable containsLowercase and assign containsLowercase with true if userString contains a lowercase letter. Otherwise, assign containsLowercase with false.
Ex: If the input is vM, then containsLowercase is assigned with true, so the output is:
Valid string
Ex: If the input is $%, then containsLowercase is assigned with false, so the output is:
Invalid string
Note: Use getline(cin, userString) to read the entire line from input into userString.
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string userString;
/* Your code goes here */
if (containsLowercase) {
cout << "Valid string" << endl;
}
else {
cout << "Invalid string" << endl;
}
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps