-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP06_QuotientAndRemainder.java
More file actions
30 lines (25 loc) · 1.13 KB
/
Copy pathP06_QuotientAndRemainder.java
File metadata and controls
30 lines (25 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package programs;
/**
* ============================================================
* PROGRAM 06: Quotient and Remainder Calculation
* ============================================================
* Problem: WAP to compute Quotient and Remainder of two numbers
* and verify the Division Algorithm: Dividend = (Divisor * Quotient) + Remainder.
* ============================================================
*/
public class P06_QuotientAndRemainder {
public static void main(String[] args) {
int dividend = 250;
int divisor = 7;
int quotient = dividend / divisor;
int remainder = dividend % divisor;
System.out.println("Dividend : " + dividend);
System.out.println("Divisor : " + divisor);
System.out.println("Quotient : " + quotient);
System.out.println("Remainder : " + remainder);
// Verification
int reconstructed = (divisor * quotient) + remainder;
System.out.println("\nVerification: (" + divisor + " * " + quotient + ") + " + remainder + " = " + reconstructed);
System.out.println("Algorithm valid? " + (reconstructed == dividend));
}
}