Question: Strings username 1 and domain 1 are read from input. Complete the try block to output Sending email to followed by username 1 and

Strings username1 and domain1 are read from input. Complete the try block to output "Sending email to " followed by username1 and domain1 with error checking:
If username1's length is <3 or >7, throw a runtime exception with the message "User name's length must be between 3 and 7".
If domain1 does not start with '@', throw a runtime exception with the message "Domain must start with '@'".
Ex: If input is Leroy @lentil, then the output is:
Sending email to Leroy@lentil
Ex: If input is Kjerstin @lentil, then the output is:
Error: User name's length must be between 3 and 7
Ex: If input is Leroy peach, then the output is:
Error: Domain must start with '@'
Notes:
username1.length() returns the length of string username1.
domain1[0]!= ch returns true if the first character of domain1 is not character ch. c++

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!