Question: Can someone explain how this code outputs the following below? I do not understand how this code is getting this output. public static void main(String[]
Can someone explain how this code outputs the following below? I do not understand how this code is getting this output.
public static void main(String[] args) { readIf(6,6); readIf(11,12); readIf(3,4); readIf(7,3); } public static void readIf(int x, int y) { if (x > y) { x = y - 2; y = 0; } else if (x == y) { x /= 2; y--; } else if (x < y - 1) { x = x % 5; } System.out.println("x: " + x + ", y: " + y); } }
Output is:
x: 3, y: 5 x: 11, y: 12 x: 3, y: 4 x: 1, y: 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
