If I remember correctly back to my school days, the rule is to use "a" if the next word starts with a consonant, or "an" if the next word is a vowel.
- This is a banana.
- This is an egg.
If the above is correct, then why does this sentence sound wrong...?
- The account requires an username.