Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Strings yourUsername and yourDomain are read from input. Complete the try block to output Email: followed by yourUsername and yourDomain with error checking: If

Strings yourUsername and yourDomain are read from input. Complete the try block to output "Email: " followed by yourUsername and yourDomain with error checking:

If yourUsername's length is < 3 or > 10, throw a runtime exception with the message "User name's length must be between 3 and 10".

If yourDomain does not start with '@', throw a runtime exception with the message "Domain must start with '@'".

Ex: If input is Sahar @endive, then the output is:

Email: Sahar@endive 

Ex: If input is Wo @endive, then the output is:

Error: User name's length must be between 3 and 10 

Ex: If input is Sahar artichoke, then the output is:

Error: Domain must start with '@' 

Notes:

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

yourDomain[0] != ch returns true if the first character of yourDomain is not character ch.

#include #include using namespace std;

int main() { string yourUsername; string yourDomain;

cin >> yourUsername; cin >> yourDomain;

try {

/* Your code goes here */

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

return 0; }

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_2

Step: 3

blur-text-image_3

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

2. What should an employer do when facing an OSHA inspection?

Answered: 1 week ago