Question: Write a method to decide whether a string contains a valid IPv 6 address in the preferred format ( each h represents a hexadecimal digit

Write a method to decide whether a string contains a valid IPv6 address in the preferred
format (each h represents a hexadecimal digit):
hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
your method must loop through individual characters in the string.
Approaches using regular expression and/or API classes like Pattern, Matcher will
receive zero credit.
Your program (i.e. your class) will have two methods, the actual method and a main(.
Start with a method stub like the one below. The main(0 will be used to test your method
with different data (see ch6.7 Unit testing).
Here are examples of valid and invalid IPv6 addresses:
Valid:
0123:4567:89ab:cdef:0123:4567:89Ab:cDEf
0000:0000:0000:dddd:eee:dddd:eeee:ffff
0000:0000:0000:0000:0000:0000:0000:0000
Invalid:
123:4567:89ab:cdef:0123:4567:89ab:cdef0-> not 4 hex digits in 1st and last
groups
0000:0000:0000 not enough digits/groups
01hg:4567:89ab:cdef:0123:4567:89ab:cdef non-hex digits in the 1st group
0123:4567::89b:cdef:0123:4567:89ab:cdef -> two colons together
Use a proper incremental development strategy to build your program. It is a good idea to
first check whether the parameter string is of the right length.
Follow the unit testing examples to add at least 3 more testing cases of your choice to
your main(): 1 valid address and 2 invalid ones.
When you are done, include a screenshot of the execution of your program in your
assignment report document. If it works properly, your program should only print those
two lines:
Testing started ...
Testing completed.
 Write a method to decide whether a string contains a valid

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!