Declare a Boolean variable named isValidPasswd. Use isValidPasswd to output "Valid" if codeStr contains no more than 4 letters and codeStr's length is less than 9, and "Invalid" otherwise.

Ex: If the input is l7J45s6f, then the output is:

Valid

Ex: If the input is n84xfj061, then the output is:

Invalid

Note: isalpha() returns true if a character is alphabetic, and false otherwise. Ex: isalpha('a') returns true. isalpha('8') returns false.

please help in c++

Answers

Answer 1

Answer: #include <iostream>

#include <string>

using namespace std;

int main() {

   string codeStr = "l7J45s6f";

   bool isValidPasswd = true;

   int letterCount = 0;

   for (char c : codeStr) {

       if (isalpha(c)) {

           letterCount++;

       }

       if (letterCount > 4 || codeStr.length() >= 9) {

           isValidPasswd = false;

           break;

       }

   }

   if (isValidPasswd) {

       cout << "Valid" << endl;

   } else {

       cout << "Invalid" << endl;

   }

   return 0;

}

Explanation: In this usage, we to begin with characterize a codeStr variable with the input string, and a isValidPasswd variable initialized to genuine. We at that point circle through each character in codeStr, increasing a letterCount variable in case the current character is alphabetic. In case the letterCount gets to be more noteworthy than 4, or in the event that the length of codeStr is more prominent than or break even with to 9, we set isValidPasswd to wrong and break out of the circle.

At last, we yield "Substantial" in case isValidPasswd is genuine, and "Invalid" something else.

Answer 2

Answer:

c++

Explanation:


Related Questions


Use one of Word's preset margins settings to change the document's margins so that the top and bottom borders are 1" and the left and right margins are 2".

Answers

In the above case, You have to:

You clicked the Review ribbon tab, clicked the References ribbon tab, clicked the Design ribbon tab, and clicked the Layout ribbon tab. In the Layout ribbon tab in the Page Setup ribbon group, you clicked the Margins button. In the Margins menu, you selected the Margin Wide gallery option.

What is the  ribbon tab about?

Change the Word document's margins to 1-inch top and bottom and 2-inch left and right using preset margin settings in the Layout tab. Click "Margins" and select "Narrow" from preset settings.

Therefore,  Set margins to 1 inch at top and bottom, 0.5 inches on left and right. Click "Custom Margins" at bottom. In "Page Setup," set margins to "2" for left and right. Click "OK" to apply changes.

Learn more about  ribbon tab from

https://brainly.com/question/24481253

#SPJ1

Other Questions
how did the causes of the revolutions in latin america differ fromthose of the other three revolutions annie is a type a individual. she is likely to display _____ behavior. alan withdraws cash from an atm belonging to bank x that is coming from his account with bank y. what is alan's relationship with bank x? you are looking at a cross section of a mountain and there are five layers that are exposed. layer 1 is at the surface, with four more layers beneath it, ending with layer 5. which layer will have the highest amount of 14n? _____ is the idea that those subject to laws should have some role in formulating them. fair dice. consider one set of tosses of two fair 4 sided die. c. what are the odds (probability) of each outcome for tossing a pair of dice? in what direction do the tails point? in what direction do the tails point? plasma tails point directly in the direction in which the comet travels. dust tails point mostly out from the sun and are bent in a direction opposite to the comet's motion. A batter hits a baseball upward with an initial speed of 96 feet per second. After how many seconds does the ball hit the ground?Use the formula h=rt-16t^2 where h represents height in feet and r represents the rate in feet per second Which factor in the expectancy theory evaluates method?a. Expectancyb. Instrumentalityc. Valenced. Motivation The air temperature in a 30 in.3 container with a free sliding piston is initially measured at 55 F. The temperature is raised to 100 F. What is the volume in the cylinder after the temperature has been raised?A. 32.6 in^3B. 54.5 in^3C. 60 psiD. 70 in^3E. 16.5 in^3 A(n) symbol in a URL indicates a query. A millennial investor who built a 25-unit real-estate portfolio in one year breaks down how she financed it and how she uses social media to source deals what is required of the application development process to ensure the application is compatible with all web browser platforms and mobile devices? when compared to boys, girls hear twice as many _____ by the time they are 32 months old. css supports styles to define both the text and ______ color for each element on your page. . 5. She played football every weekend, she lost weight. (Begin: Playing.. What does the phase angle in the frequency domain correlate to in the time domain . if a consumer makes monthly payments of $250 to pay off a car loan, what type of credit is she using? (1 point) non-revolving revolving short term unsecured A solid of mass 1.3kg, suspended by a string is completely in water. If the tension in the string is 6.0N, calculate;i) the upthrust on the solidii) volume of the solidiii) its density(g=10m/s^2 , density of water=1000kg/m^3) why does the design of a store have long-term effects on building customer loyalty toward the retailer?