Hey guys,
A few newbie questions on Java programming:
I have a program code here:
Apparantely that is supposed to yield:
I'm not sure how the code makes the result it's supposed to make. In particular, i don't quite understand that "z = mystery(x, z, y);" stuff (along with other stuff).
Thanks!
A few newbie questions on Java programming:
I have a program code here:
public class Mystery {
public static void main(String[] args) {
int x = 1, y = 2, z = 3;
z = mystery(x, z, y);
System.out.println(x + " " + y + " " + z);
x = mystery(z, z, x);
System.out.println(x + " " + y + " " + z);
y = mystery (y, y, z);
System.out.println(x + " " + y + " " + z);
}
public static int mystery(int z, int x, int y) {
z--;
x= 2 * y + z;
y = x - 1
System.out.println(y + " " + z);
return x;
}
}Apparantely that is supposed to yield:
3 0 1 2 3 4 3 5 2 4 8 1 5 9 4
I'm not sure how the code makes the result it's supposed to make. In particular, i don't quite understand that "z = mystery(x, z, y);" stuff (along with other stuff).
Thanks!

Help
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Back to top










