Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Strings username1 and password1 are read from input. Complete the try block to output username1 followed by : Access granted with error checking: If the

Strings username1 and password1 are read from input. Complete the try block to output username1 followed by ": Access granted" with error checking:

If the first character of username1 is not a letter, throw a runtime exception with the message "User name must start with a letter".

If password1's length is < 7, throw a runtime exception with the message "Password is too short".

Ex: If input is Astrid asparagus, then the output is:

Astrid: Access granted 

Ex: If input is !Maricruz asparagus, then the output is:

Error: User name must start with a letter 

Ex: If input is Astrid leek, then the output is:

Error: Password is too short 

Notes:

isalpha(username1[0]) returns true if the first character of username1 is a letter.

password1.length() returns the length of string password1.

#include #include using namespace std;

int main() { string username1; string password1;

cin >> username1; cin >> password1;

try {

/* Your code goes here */

} catch (runtime_error& excpt) { cout << "Error: " << excpt.what() << endl; }

return 0; }

c++ and pleasee please make it correct

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions