Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!