Q:

Java Remainder of Integer Divison?

I was searching around about this topic but I still don't get it, if someone can elaborate I would be very thankful.
My task is to divide two variables as integer division with remainder..
The problem is, that I have no clue what a remainder is, for now I did something like that, this is what I found by searching through the internet:
int a;
int b;
int remainder = Math.Pow(a,2) % b;

System.out.println("a^2 / b = " + Math.Pow(a,2) / b);
System.out.println("remainder = " + remainder);

if I for example set (a = 43) and (b = 67)
Then I will get this reslut:
a^2 / b = 27
remainder = 40

Now since I have no idea what the remainder is (this is just a suggestion form the internet) I have no idea if this is the correct answer..?
Thanks for any help,
Kind Regards

A:

If you are looking for the mathematical modulo operation you could use
int x = -22;
int y = 24;
System.out.println(Math.floorMod(x, y));

If you are not interested in the mathematical modulo (just the remainder) then you could use
int x = -22;
int y = 24;
System.out.println(x%y);

A:

    public static void main(String[] args) {
        int dividend = 139, divisor = 7;

        int quotient = dividend / divisor;
        int remainder = dividend % divisor;

        System.out.println("The Quotient is = " + quotient);
        System.out.println("The Remainder is = " + remainder);
    }

Output:

The Quotient is = 19
The Remainder is = 6

