You might want to calculate the remainder from an integer division, not throw it away. For that, Java provides a special operator, modulus (%), to retrieve the remainder.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | package javaexamples; import java.util.Scanner; public class JavaExamples { public static void main(String[] args) { int dividend = 450, divisor = 8; int remainder = dividend % divisor; String output1 = String.format("dividend:%d \ndivisor:%d",dividend,divisor); String output2 = String.format("\nRemainder =%d ",remainder); System.out.println(output1); System.out.println(output2); } } |