I have two codes for this one, the first one using the modulus operator and the second one not using the modulus operator

//Using the modulus operator. import java.util.Scanner; class RicMain { public static void main(String args[]) { Scanner a = new Scanner(System.in); int x, y, z; System.out.print("Enter first integer: "); x = a.nextInt(); System.out.print("Enter second integer: "); y = a.nextInt(); z = x % y; System.out.println("The modulus of x and y is: " + z); } }

Now, for the second code, I do not understand//not using the modulus operator import java.util.Scanner; class RicMain { public static void main(String args[]) { Scanner a = new Scanner(System.in); int x, y, divided, result; System.out.print("Enter first integer: "); x = a.nextInt(); System.out.print("Enter second integer: "); y = a.nextInt(); divided = (x / y); result = (x - (divided * y)); System.out.println("The modulus of x and y is: " + result); } }

divided = (x / y);

result = (x - (divided * y));

When I start with the integers 19 and 7, for the first one is 5, but for the second one, when I try to do it on a calculator, it prints out something totally different, but on Java, it prints out 5? Why is that?