Question: Name this program StuPreIPv 6 ) Each network device must be assigned an IP address. An IPv 6 ( IP address version 6 ) address

Name this program StuPreIPv6) Each network device must be assigned an IP address. An IPv6
(IP address version 6) address is represented in the preferred format as eight groups of four
hexadecimal digits. A hexadecimal digit may be 0 ~ 9 or a ~ f (or A ~ F). The groups are separated
by colons (:). An example of an IPv6 address in the preferred format is:
2001:0db8:85a3:0000:0000:8a2e:0370:7001
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
For this assignment, 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() will be used to test your method with different data (see
ch6.7 Unit testing).
// Returns true if the string parameter contains a valid IPv6
// address in the preferred format. Otherwise returns false.
public static boolean isValidPreferFormatIpv6(String address){
return false;
}
// for unit testing: test the method with different arguments
public static void main(String[] args){
System.out.println("Testing started ...");
String str; // store a test string
boolean expected; // expected result of true or false for the test string
str =""; // an invalid string
expected = false;
if (isValidPreferFormatIpv6(str)!= expected)
System.out.println("Test: "+ str +"- failed");
str ="0123:4567:89ab:cdef:0123:4567:89ab:cDEf"; // valid
expected = true;

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 Finance Questions!