I need help finding a remainder

Hey guys im writing a program for my computer science class and its kicking my ass. The think im having a problem with is making it tell me what the remainder is im using the modulous *correctly i think* but it keeps being weird. Ill show you the code ive wrote so far

import java.util.Scanner;

public class Prog72a

Code:

`{`

public static void main(String args[])

{

int a,b,c,d;

int e = 26;

Scanner aa = new Scanner(System.in);

System.out.println("imput the first two numbers");

a = aa.nextInt();

Scanner bb = new Scanner(System.in);

System.out.println("imput the second two numbers");

b = bb.nextInt();

Scanner cc = new Scanner(System.in);

System.out.println("imput the third two numbers");

c = cc.nextInt();

Scanner dd = new Scanner(System.in);

System.out.println("imput the fourth two numbers");

d = dd.nextInt();

int f = a + b + c + d % e;

System.out.println("The remainder is" + f);

}

}

So at the point im at now it should tell me what the remainder is of the 4 two digit numbers i put in divided by 26 but when i do for some reason it will just add the 4 two digit numbers up and tell me what their sum is...unless i do "26 26 26 26" then it tells me the sum of the four 26's but it subtracts 26 so the number it shows me is 78. Please help guys, i really have no clue whats wrong, i think im using the modulous wrong.

Re: I need help finding a remainder

You have to follow the rules of operator precedence when you are using arithmetic expressions. Here '%' is having a higher precedence than '+' hence the operation that will be first performed here is modulus and the result will be added with the other variables. Use the expression "(a+b+c+d)%d". This should solve your problem. Let me know if it doesn't

Re: I need help finding a remainder

Thanks a lot, i feel dumb now.