Does anyone get this? I've never used Java but magically I'm suposed to know how to do this

Consider the following code fragment in Java. The code examines the values of 4 integer variables (called ‘a’, ‘b’, ‘c’ and ‘d’). Depending on the value of these 4 variable, the flow-of-control in the code will move on to different lines of code. We wish to do glass-box testing of this code. For this problem you must find a set of values for the 4 variables to guarantee that LINE 1 is executed. Then you must find another set of 4 values to guarantee that LINE 2 is executed, etc. You should provide 8 different sets of the 4 values a, b, c, and d that together would insure that every line of code in this small program is executed by at least one of the 8 sets of values.

if ( a < b ) {

if ( c < d ) {

  if ( a < c )

     System.out.println ( a );   /* LINE 1 */

   else

     System.out.println ( c );   /* LINE 2 */

else {

   if ( a < d )

      System.out.println ( a );  /* LINE 3 */

   else

      System.out.println ( d );  /* LINE 4 */

}

}

else {

if ( d < c) {

  if ( b < d )

     System.out.println ( b );  /* LINE 5 */

   else

     System.out.println ( d );  /* LINE 6 */   

 }

 else {

    if ( b < c )

       System.out.println ( b );  /* LINE 7 */

    else

       System.out.println ( c );  /* LINE 8 */

 }

}

Hi iXLnu,

Pasting this code into an IDE shows that there is syntax error in it. Isn’t there a closing bracelet before the 2nd else?
Something like:

Apart from that, this isn’t that much of a Java, but rather a Boolean logic task. For example,

Can be broken down to:

LINE 1: a < b & c < d & a < c, so valid values for exiting at LINE 1 would be:
a = 1
b = 2
c = 3
d = 4

Only one “false” branch away should be LINE 2: a < b & c < d & a >= c, so you could add these values to the variables:
a = 5
b = 6
c = 4 (or even 5)
d = 8

I can’t calculate further due to the syntax error, but the process is the same all the way long.

Sandmann

Thanks for the help Sandmann,

I double checked and this is the way my teacher posted this problem ( she tends to have typos here and there). Like I say we have never done anything like this before, she talked about something slightly similar to this in class for a few minutes. But that was about it, I have no reference to go off, because it’s no where in the book I am using. This was the message she sent me “I am asking for particular values of a, b, c and d such as 1, 2, 3 and 4. Yes, you can use the exact same 4 values for each of the 8-sets, but each time you re-arrange the order of the values ( which number is a, which number is b, etc)”.