Homework: Email to NetID - Need Help

This post was flagged by the community and is temporarily hidden.

Next time, please don’t post your solution code because it spoils the problem for anyone else who stumbles across this post.

Also, you should try to be more informative about what error you are running into and what else you have tried so other people can try to help out for that specific question.

Finally, some actual help:
Your assert statement should always be one of the first things you do in a method. Currently, your code first checks if the input string contains β€œ@illinois.edu”, but if your input string is null, you will run into an error immediately. If your assert that the input is not null as the first line of your method, you would not run into your error at all.

Hope this helps!


What ditty said, please do not post your code.

Anyway, there are a few ways to do this. Maybe review java documentation for how split works. And your assert statement does not really make sense either.

So split: if I have dajds4@illinois.edu, then once I split I would have a string array contating dajds4. If we do .split(β€œ@”) we would get {dajds4, illinois.edu).

Second, what if the email is @illinois.edusss or some typo on the end? you would not pass that test case.

Review your assert statement. Look at how i told you to use the split with just β€œ@”. you can say

assert something[index] = "what your are checking for"

finally, with your array, you can use the indexing to pull whatever it is youre looking for. This should give enough hints, but if you are still stuck let me know.

String sum = "james/idask/sdfasd";
String[] arr = sum.split("/");
for (int i = 0; i < arr.length; i++) {

hopefully this example on how you can work with code will help you.

1 Like