F4LLCON F4LLCON - 1 year ago 175
Java Question

Java 'Write the code necessary to "left rotate" their values:'

I've tried a lot of combinations and have searched on the web for something useful but unfortunately I've found nothing useful.

This is for my homework. Only question I cannot answer out of 69 questions.


Four integer variables, pos1, pos2, pos3, pos4 have been declared and initialized. Write the code necessary to "left rotate" their values: for each variable to get the value of the successive variable, with pos4 getting pos1's value.

Example that I've tried:

int tempP1 = pos1;
int tempP2 = pos2;
int tempP3 = pos3;
int tempP4 = pos4;

pos4 = tempP1;
pos3 = tempP2;
pos2 = tempP3;
pos1 = tempP4;

What it shows me:

     ⇒     Your code had an error during execution

More Hints:
     ⇒     Are you sure you want to use: tempP1
     ⇒     Are you sure you want to use: tempP2
     ⇒     Are you sure you want to use: tempP3

Problems Detected:
     ⇒     pos1 has wrong value
     ⇒     pos3 has wrong value

Answer Source
pos4 = tempP1;
pos2 = tempP3;
pos3 = tempP4;
pos1 = tempP2;

Sounds right?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download