Concept explainers
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 nowThis is a popular solution!
Step by stepSolved in 3 steps
- Program Purpose - Professional Athletes often hire other professionals to help take care of matters for them. We will group them in four categories: Lawyers, Personal Assistants, Agents, and Trainers. They all get paid a percentage of the athlete's total yearly salary. Lawyers - 10%, Personal Assistants - 3%, Agents - 7%, and Trainers - 5% . Prompt the user to enter the athlete's salary for the year (ensure that the entered value is positive). The user should then enter the name and category of each of the hired professionals. The athlete should be able to hire as many professionals in each category as he/she wants, even if it is more than he/she can afford. Based on the category, calculate the amount that each professional should be paid. After all data has been entered, print the names of each professional hired, how much each is being paid, the total amount the athlete paid, and how much the athlete has left.arrow_forwardThe isupper method converts a string to all uppercase characters.True or Falsearrow_forwardWrite a substring expression to extract "Exam" from the following String. String str= "Final Exam";arrow_forward
- which functions you would use to read the following string from a users input: "This is a fun day" A. cin >> B. cin.get function c. getline function d. all of the abovearrow_forwardProblem 1. Each of the following assembly code snippets corresponds to the body of a C function consisting of a single control structure: a loop, if statement, or case switch. (Compiler directives, like cfi_startproc, and instructions that do not affect the semantics, like endbr64, have been removed for readability. And yes, of course the functions are all named foo.) For each one, write C code that would compile to similar assembly for the body. In other words, figure out what the code is doing and write C code to do that. You will have to figure out how many variables are being computed with, and make up names for them. (The code was compiled with -0g.) foo: a. b. C. .L3: .L2: foo: .L2: foo: .L3: .L2: movl $0, %edx movl $0, %eax jmp .L2 addl (%rdi), %edx addl $1, %eax leaq 4(%rdi), %rdi cmp1 %esi, %eax jl .L3 movl %edx, %eax ret movl (%rdi), %eax cmpl $10, %eax jle .L2 subl $10, %eax movl %eax, (%rdi) ret leal 1(%rax,%rax, 2), %eax movl %eax, (%rdi) ret movl $0, %eax jmp .L2 addl $1,…arrow_forwardWhich statement is a legal statement? Group of answer choices A.string & bad1 = “hello”; B.string & bad2 = str + “ ”; C.string & sub = str.substr( 0, 4); D.string && bad1 = “hello”; E.All of the abovearrow_forward
- // A standard mortgage is paid monthly over 30 years. // This program is intended to display 360 payment coupons // for a new borrower. Each coupon lists the month number, // year number, and a friendly mailing reminder. start num MONTHS = 12 num YEARS = 30 string MSG = "Remember to allow 5 days for mailing" num monthCounter = 0 num yearCounter = 30 while yearCounter <= YEARS while monthCounter <= MONTHS output monthCounter, yearCounter, MSG endwhile endwhile stop housekeeping() print "Enter account number or ", QUIT, " to quit " return printCoupons() while yearCounter <= YEARS while monthCounter <= MONTHS print acctNum, monthCounter, yearCounter, MSG monthCounter = monthCounter + 1 endwhile yearCounter = yearCounter + 1 endwhile output "Enter account number or ", QUIT, " to quit " input acctNum return finish() output "End of job" returnarrow_forwardGiven a String variable named brand that has been declared and initialized, write the statement needed to create a new integer variable named numChars that contains the number of characters in the String. int numChars =arrow_forwardcolor: one of the following strings: 'red', 'blue', 'silver', 'white', 'black'year: year of manufacturing. A number between 1990 and 2018company: one of the following strings: 'Honda', 'Toyota', 'Ford', 'Chevrolet'model: one of the following strings: 'sedan', 'hatchback', 'SUV'Give a logical expression that evaluates to a True or False for a set of cars. e.g. Expression for "Red SUV cars" is (color == "red" and model == "SUV") Give an expression for "Ford sedan cars that are red or blue and were manufactured after 2000"arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education