68.0k views
4 votes
Given four int variables that have been given values, octet1, octet2, octet3, and octet4, write a string expression whose value is the string equivalent of each these variables joined by a single period (.) So if octet1, octet2, octet3, and octet4, had the values 129, 42, 26, and 212 the expression's value would be "129.42.26.212". Alternatively, if octet1, octet2, octet3, and octet4, had the values 192, 168, 1and 44 the expression's value would be "192.168.1.44".

User Whoplisp
by
5.9k points

1 Answer

0 votes

Answer:

String cocat =octet1+"."+octet2+"."+octet3+"."+octet4;

Step-by-step explanation:

See a complete java code below:

public class num15 {

public static void main(String[] args) {

int octet1 = 192;

int octet2 = 168;

int octet3 = 1;

int octet4 = 44;

String cocat =octet1+"."+octet2+"."+octet3+"."+octet4;

System.out.println(cocat);

}

}

User Rafael Shkembi
by
5.9k points