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; }

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter3: Coding With Variables, Named Constants, And Calculations
Section: Chapter Questions
Problem 2MQ2
icon
Related questions
Question

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;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning