Use integer division to divide a by b, then the result times b plus the remainder equals a. - Java Language Basics

Java examples for Language Basics:Operator

Description

Use integer division to divide a by b, then the result times b plus the remainder equals a.

Demo Code

public class Main {
  public static void main(String[] args) {
    int a = 29;           // any value will do
    int b = 3;            // any value will do
    int c = a / b;
    int d = a % b;
    int e = (c * b) + d;  // e will always equal a
    System.out.println(e);//from w  ww .jav  a2  s.  co m

  }

}

Related Tutorials