Chat room ao vivi gerls - Validating social security number java

a) if at the appropriate index the char is a digit, otherwise return false b) if at the appropriate index the char is a dash, otherwise return false If all char pass your logic, then return true. [EDIT to address your bug: SPOILER ALERT If you keeping reading I am giving away the answer.You also have some code in your main that I'm unsure what is going on, namely, But I think once you get 1. So keep at it and if you give up, look below and figure out why this works and your code doesn't.

validating social security number java-3

So If I were to input 1, It would say that "1 is a valid SSN", and I were to input 123/56/7890 or 123-567-890 it would say that ""123-567-890" or "123-567-890" is not a SSN".

Can someone help me with verifying that the input is a SSN.

It's kind of a cheat because Scanner most likely uses a Reg Ex internally but you'll never know because the class hides those details from you. — Junilu [How to Ask Questions] [How to Answer Questions] BTW, Leesa, if you're posting code snippets, click on the "Code" button in the editor and put your code snippets between the code "tags" that get created.

That will make your code display nicely when you post your message, assuming you format it nicely in the editor.

As you loop through each char, check each one in is Digit(char c) and is Dash(char c). Test your code on this string "123-45--789" and you'll see it also passes.

You should be able to google how to "loop through each char in string in java" to find your first answer. The reason is because you are only checking the first char and if it passes your logic, then return true. So rethink your loop so that you can pull the return true out of the for loop. Each of these chars hold a position in the string 's', starting from index 0 through 10. If you're not seeing something helpful check out this link.

Social Security Numbers This blog post focuses on validating the last of those: Social Security Numbers and why they may be a bit deceivingly more difficult to validate than you might expect.

I’ll provide a few different methods to handle the actual validation through Regular Expressions and let you determine which one might best suit your needs.

I am looking for ideas on alternate ways to accomplish this problem. I have it working I am just looking for other ways to solve this with an array maybe or something simpler.

I have used if statements here: Hi Leesa, Welcome to the Ranch!

Here is what I have so far: So, I have written out the header for the main method, and the header for the boolean method that checks to see if there are 11 characters, a header for a boolean method that checks to see if the numbers are in the right place, and a header for a boolean method that checks to see if the dashes are in the right place.

Comments are closed.