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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!