When you divide two int values, Java truncates the result. It does not round. It just chops off everything after the decimal point. So 7 / 2 gives 3, not 4.
If you need the decimal result, at least one operand must be a double.
int a = 7;
int b = 2;
System.out.println(a / b); // 3
System.out.println((double) a / b); // 3.5
System.out.println(7.0 / 2); // 3.5
The (double) in front of a is a cast. It converts a to a double before the division happens. Writing 7.0 instead of 7 also works because the compiler treats 7.0 as a double literal. If you forget this rule, your calculations will silently produce wrong answers.