Question: Exceptions You are making a program to manage user names. A valid username needs to be minimum 4, maximum 20 characters long. Create a program

Exceptions

You are making a program to manage user names. A valid username needs to be minimum 4, maximum 20 characters long. Create a program to take a string as input, check its length and output "Valid" if the name is valid, or "Invalid", if it is not.

You can check the length of the input string using the size() function and throw an exception, if it is not valid.

#include

using namespace std;

int main() {

string name;

cin >> name;

try {

}

catch(int x) {

}

return 0;

}

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!