Question: C + + 1 4 . 1 . 2 : Exception basics. 5 8 2 8 8 0 . 4 2 5 8 2 9

C++
14.1.2: Exception basics.
582880.4258294.qx3zqy7
Jump to level 1
Strings yourUsername and yourDomain are read from input. Complete the try block to output "Sending email to " followed by yourUsername and yourDomain with error checking:
If yourUsername's length is <3 or >7, throw a runtime exception with the message "User name's length must be between 3 and 7".
If yourDomain does not start with '@', throw a runtime exception with the message "Domain must start with '@'".
Ex: If input is Amir @leek, then the output is:
Sending email to Amir@leek
Ex: If input is Svetlana @leek, then the output is:
Error: User name's length must be between 3 and 7
Ex: If input is Amir lettuce, then the output is:
Error: Domain must start with '@'

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 Programming Questions!